Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-29373: [CS] Switched codebase to use short array syntax #2597

Merged
merged 2 commits into from Jun 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .php_cs
Expand Up @@ -6,7 +6,7 @@ return PhpCsFixer\Config::create()
'@Symfony' => true,
'@Symfony:risky' => true,
'concat_space' => ['spacing' => 'one'],
'array_syntax' => false,
'array_syntax' => ['syntax' => 'short'],
'simplified_null_return' => false,
'phpdoc_align' => false,
'phpdoc_separation' => false,
Expand Down
Expand Up @@ -53,6 +53,6 @@ public function getRepositoryConfig()
);
}

return array('alias' => $repositoryAlias) + $this->repositories[$repositoryAlias];
return ['alias' => $repositoryAlias] + $this->repositories[$repositoryAlias];
}
}
10 changes: 5 additions & 5 deletions eZ/Bundle/EzPublishCoreBundle/ApiLoader/RepositoryFactory.php
Expand Up @@ -57,7 +57,7 @@ class RepositoryFactory implements ContainerAwareInterface
*
* @var \eZ\Publish\SPI\Limitation\Type[]
*/
protected $roleLimitations = array();
protected $roleLimitations = [];

/**
* @var array
Expand Down Expand Up @@ -111,16 +111,16 @@ public function buildRepository(
$searchHandler,
$backgroundIndexer,
$relationProcessor,
array(
[
'fieldType' => $this->fieldTypeCollectionFactory->getFieldTypes(),
'nameableFieldTypes' => $this->fieldTypeNameableCollectionFactory->getNameableFieldTypes(),
'role' => array(
'role' => [
'limitationTypes' => $this->roleLimitations,
'policyMap' => $this->policyMap,
),
],
'languages' => $this->configResolver->getParameter('languages'),
'content' => ['default_version_archive_limit' => $config['options']['default_version_archive_limit']],
),
],
new UserReference($this->configResolver->getParameter('anonymous_user_id')),
$this->logger
);
Expand Down
Expand Up @@ -27,7 +27,7 @@ class SearchEngineFactory
*
* @var \eZ\Publish\SPI\Search\Handler[]
*/
protected $searchEngines = array();
protected $searchEngines = [];

public function __construct(RepositoryConfigurationProvider $repositoryConfigurationProvider)
{
Expand Down
Expand Up @@ -27,7 +27,7 @@ class StorageEngineFactory
*
* @var \eZ\Publish\SPI\Persistence\Handler[]
*/
protected $storageEngines = array();
protected $storageEngines = [];

public function __construct(RepositoryConfigurationProvider $repositoryConfigurationProvider)
{
Expand Down
4 changes: 2 additions & 2 deletions eZ/Bundle/EzPublishCoreBundle/Assetic/AssetFactory.php
Expand Up @@ -39,7 +39,7 @@ public function setDynamicSettingParser(DynamicSettingParserInterface $dynamicSe
*
* {@inheritdoc}
*/
protected function parseInput($input, array $options = array())
protected function parseInput($input, array $options = [])
{
if ($this->dynamicSettingParser->isDynamicSetting($input)) {
$parsedSettings = $this->dynamicSettingParser->parseDynamicSetting($input);
Expand All @@ -50,7 +50,7 @@ protected function parseInput($input, array $options = array())
);

if (is_array($input)) {
$collection = $this->createAssetCollection(array(), $options);
$collection = $this->createAssetCollection([], $options);
foreach ($input as $file) {
$collection->add(parent::parseInput($file, $options));
}
Expand Down
Expand Up @@ -28,7 +28,7 @@ public function getData($key)

public function storeData($key, $data, $expiration)
{
$store = igbinary_serialize(array('data' => $data, 'expiration' => $expiration));
$store = igbinary_serialize(['data' => $data, 'expiration' => $expiration]);
if (null === $expiration) {
return $this->redis->set($this->makeKeyString($key), $store);
} else {
Expand Down
Expand Up @@ -30,7 +30,7 @@ public function storeData($key, $data, $expiration)
{
lzf_optimized_for(0);

$store = lzf_compress(igbinary_serialize(array('data' => $data, 'expiration' => $expiration)));
$store = lzf_compress(igbinary_serialize(['data' => $data, 'expiration' => $expiration]));
if (null === $expiration) {
return $this->redis->set($this->makeKeyString($key), $store);
} else {
Expand Down
Expand Up @@ -30,7 +30,7 @@ public function storeData($key, $data, $expiration)
{
lzf_optimized_for(0);

$store = lzf_compress(serialize(array('data' => $data, 'expiration' => $expiration)));
$store = lzf_compress(serialize(['data' => $data, 'expiration' => $expiration]));
if (null === $expiration) {
return $this->redis->set($this->makeKeyString($key), $store);
} else {
Expand Down
Expand Up @@ -53,7 +53,7 @@ public function __construct(
*/
public function buildProxyClient(array $servers, $baseUrl)
{
$allServers = array();
$allServers = [];
foreach ($servers as $server) {
if (!$this->dynamicSettingParser->isDynamicSetting($server)) {
$allServers[] = $server;
Expand Down
20 changes: 10 additions & 10 deletions eZ/Bundle/EzPublishCoreBundle/Command/TestInitDbCommand.php
Expand Up @@ -33,11 +33,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$database = $this->getContainer()->get('ezpublish.connection')->getConnection()->getParams();
if (is_array($database)) {
$driverMap = array(
$driverMap = [
'pdo_mysql' => 'mysql',
'pdo_pgsql' => 'pgsql',
'pdo_sqlite' => 'sqlite',
);
];

$dbType = $driverMap[$database['driver']];
$database = $database['dbname'];
Expand Down Expand Up @@ -71,12 +71,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
public function insertData($dbType)
{
// Get Initial fixture data and union with some tables that must be present but sometimes aren't
$data = $this->getInitialData() + array(
'ezcontentobject_trash' => array(),
'ezurlwildcard' => array(),
'ezmedia' => array(),
'ezkeyword' => array(),
);
$data = $this->getInitialData() + [
'ezcontentobject_trash' => [],
'ezurlwildcard' => [],
'ezmedia' => [],
'ezkeyword' => [],
];
$handler = $this->getDatabaseHandler();
foreach ($data as $table => $rows) {
// Cleanup before inserting
Expand All @@ -94,7 +94,7 @@ public function insertData($dbType)
$q->insertInto($handler->quoteIdentifier($table));

// Contains the bound parameters
$values = array();
$values = [];

// Binding the parameters
foreach ($rows[0] as $col => $val) {
Expand Down Expand Up @@ -142,7 +142,7 @@ protected function getPostInsertStatements($dbType)
return array_filter(preg_split('(;\\s*$)m', file_get_contents($setvalPath)));
}

return array();
return [];
}

/**
Expand Down
6 changes: 3 additions & 3 deletions eZ/Bundle/EzPublishCoreBundle/Controller/PageController.php
Expand Up @@ -21,13 +21,13 @@
*/
class PageController extends BasePageController
{
public function viewBlock(Block $block, array $params = array(), array $cacheSettings = array())
public function viewBlock(Block $block, array $params = [], array $cacheSettings = [])
{
// Inject valid items as ContentInfo objects if possible.
if ($this->pageService instanceof CoreBundlePageService) {
$params += array(
$params += [
'valid_contentinfo_items' => $this->pageService->getValidBlockItemsAsContentInfo($block),
);
];
}

return parent::viewBlock($block, $params, $cacheSettings);
Expand Down
Expand Up @@ -25,10 +25,10 @@ public function process(ContainerBuilder $container)

$assetFactoryDef = $container->findDefinition('assetic.asset_factory');
$assetFactoryDef
->addMethodCall('setConfigResolver', array(new Reference('ezpublish.config.resolver')))
->addMethodCall('setConfigResolver', [new Reference('ezpublish.config.resolver')])
->addMethodCall(
'setDynamicSettingParser',
array(new Reference('ezpublish.config.dynamic_setting.parser'))
[new Reference('ezpublish.config.dynamic_setting.parser')]
);
}
}
Expand Up @@ -33,6 +33,6 @@ private function addCall(ContainerBuilder $container, Reference $reference, $tar
}

$definition = $container->findDefinition($targetServiceName);
$definition->addMethodCall('setDownloadUrlGenerator', array($reference));
$definition->addMethodCall('setDownloadUrlGenerator', [$reference]);
}
}
Expand Up @@ -40,10 +40,10 @@ public function process(ContainerBuilder $container)

$chainResolver->addMethodCall(
'addResolver',
array(
[
new Reference($id),
$priority,
)
]
);
}
}
Expand Down
Expand Up @@ -32,20 +32,20 @@ public function process(ContainerBuilder $container)
// The default router will be given the highest priority so that it will be used by default
if ($container->hasDefinition('router.default')) {
$defaultRouter = $container->getDefinition('router.default');
$defaultRouter->addMethodCall('setSiteAccess', array(new Reference('ezpublish.siteaccess')));
$defaultRouter->addMethodCall('setConfigResolver', array(new Reference('ezpublish.config.resolver')));
$defaultRouter->addMethodCall('setSiteAccess', [new Reference('ezpublish.siteaccess')]);
$defaultRouter->addMethodCall('setConfigResolver', [new Reference('ezpublish.config.resolver')]);
$defaultRouter->addMethodCall(
'setNonSiteAccessAwareRoutes',
array('%ezpublish.default_router.non_siteaccess_aware_routes%')
['%ezpublish.default_router.non_siteaccess_aware_routes%']
);
$defaultRouter->addMethodCall(
'setSiteAccessRouter',
array(new Reference('ezpublish.siteaccess_router'))
[new Reference('ezpublish.siteaccess_router')]
);
if (!$defaultRouter->hasTag('router')) {
$defaultRouter->addTag(
'router',
array('priority' => 255)
['priority' => 255]
);
}
}
Expand All @@ -62,10 +62,10 @@ public function process(ContainerBuilder $container)

$chainRouter->addMethodCall(
'add',
array(
[
new Reference($id),
$priority,
)
]
);
}
}
Expand Down
Expand Up @@ -37,13 +37,13 @@ public function __construct(DynamicSettingParserInterface $dynamicSettingParser)

public function process(ContainerBuilder $container)
{
$dynamicSettingsServices = array();
$resettableServices = array();
$dynamicSettingsServices = [];
$resettableServices = [];
$updateableServices = $container->getParameter('ezpublish.config_resolver.updateable_services');
// Pass #1 Loop against all arguments of all service definitions to replace dynamic settings by the fake service.
foreach ($container->getDefinitions() as $serviceId => $definition) {
// Constructor injection
$replaceArguments = array();
$replaceArguments = [];
foreach ($definition->getArguments() as $i => $arg) {
if (!$this->dynamicSettingParser->isDynamicSetting($arg)) {
continue;
Expand Down Expand Up @@ -78,7 +78,7 @@ public function process(ContainerBuilder $container)
$callHasDynamicSetting = true;
}

$call = array($method, $callArgs);
$call = [$method, $callArgs];
if ($callHasDynamicSetting) {
// We only support single dynamic setting injection for updatable services.
if (count($callArgs) == 1) {
Expand Down
Expand Up @@ -27,7 +27,7 @@ public function process(ContainerBuilder $container)
return;
}

$warmers = array();
$warmers = [];
foreach ($container->findTaggedServiceIds('kernel.cache_warmer') as $id => $attributes) {
if ($id === 'kernel.class_cache.cache_warmer') {
continue;
Expand Down
Expand Up @@ -41,11 +41,11 @@ public function process(ContainerBuilder $container)

$parameterProviderRegistryDef->addMethodCall(
'setParameterProvider',
array(
[
// Only pass the service Id since field types will be lazy loaded via the service container
new Reference($id),
$attribute['alias'],
)
]
);
}
}
Expand Down
Expand Up @@ -45,7 +45,7 @@ public function process(ContainerBuilder $container)
$container->setDefinition($renamedId, $definition);

$decoratedDef = new DefinitionDecorator('ezpublish.decorated_fragment_renderer');
$decoratedDef->setArguments(array(new Reference($renamedId)));
$decoratedDef->setArguments([new Reference($renamedId)]);
$decoratedDef->setPublic($public);
$decoratedDef->setTags($tags);
// Special treatment for inline fragment renderer, to fit ESI renderer constructor type hinting (forced to InlineFragmentRenderer)
Expand Down
Expand Up @@ -24,7 +24,7 @@ public function process(ContainerBuilder $container)
foreach ($container->findTaggedServiceIds('ezpublish.identity_definer') as $id => $attributes) {
$hashGeneratorDef->addMethodCall(
'setIdentityDefiner',
array(new Reference($id))
[new Reference($id)]
);
}
}
Expand Down
Expand Up @@ -22,7 +22,7 @@ public function process(ContainerBuilder $container)
}

$filterConfigDef = $container->findDefinition('liip_imagine.filter.configuration');
$filterConfigDef->addMethodCall('setConfigResolver', array(new Reference('ezpublish.config.resolver')));
$filterConfigDef->addMethodCall('setConfigResolver', [new Reference('ezpublish.config.resolver')]);

if ($container->hasAlias('liip_imagine')) {
$imagineAlias = (string)$container->getAlias('liip_imagine');
Expand Down
Expand Up @@ -39,11 +39,11 @@ public function process(ContainerBuilder $container)

$legacyStorageEngineDef->addMethodCall(
'registerFieldType',
array(
[
// Only pass the service Id since field types will be lazy loaded via the service container
$id,
$attribute['alias'],
)
]
);
}
}
Expand All @@ -69,10 +69,10 @@ public function process(ContainerBuilder $container)

$legacyStorageEngineDef->addMethodCall(
'registerFieldTypeConverter',
array(
[
$attribute['alias'],
$converter,
)
]
);
}
}
Expand Down
Expand Up @@ -30,7 +30,7 @@ public function process(ContainerBuilder $container)

$localeListenerDef = $container->getDefinition('locale_listener');
// Injecting the service container for lazy loading purpose, since all event listeners are instantiated before events are triggered
$localeListenerDef->addMethodCall('setConfigResolver', array(new Reference('ezpublish.config.resolver')));
$localeListenerDef->addMethodCall('setLocaleConverter', array(new Reference('ezpublish.locale.converter')));
$localeListenerDef->addMethodCall('setConfigResolver', [new Reference('ezpublish.config.resolver')]);
$localeListenerDef->addMethodCall('setLocaleConverter', [new Reference('ezpublish.locale.converter')]);
}
}
Expand Up @@ -54,10 +54,10 @@ public function process(ContainerBuilder $container)
// Register the search engine with the search engine factory
$searchEngineFactoryDefinition->addMethodCall(
'registerSearchEngine',
array(
[
new Reference($id),
$attribute['alias'],
)
]
);
}
}
Expand Down
Expand Up @@ -44,10 +44,10 @@ public function process(ContainerBuilder $container)
// Register the storage engine on the main storage engine factory
$storageEngineFactoryDef->addMethodCall(
'registerStorageEngine',
array(
[
new Reference($id),
$attribute['alias'],
)
]
);
}
}
Expand Down