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

[console] Convert array short syntax. #3057

Merged
merged 1 commit into from
Jan 1, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<?php

return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL);
return PhpCsFixer\Config::create()
->setRules(
[
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
]
)
->setUsingCache(false);
6 changes: 3 additions & 3 deletions phpqa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ application:
php-cs-fixer:
enabled: true
exception: false
file:
config-file: .php_cs
single-execution: false
# file:
# config-file: .php_cs
# single-execution: false
options:
level: psr2
arguments:
Expand Down
1 change: 1 addition & 0 deletions src/Annotations/DrupalCommandAnnotationReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* Class DrupalCommandReader
*
* @package Drupal\Console\Annotations
*/
class DrupalCommandAnnotationReader
Expand Down
9 changes: 8 additions & 1 deletion src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

/**
* Class Application
*
* @package Drupal\Console
*/
class Application extends BaseApplication
Expand Down Expand Up @@ -70,7 +71,13 @@ private function registerGenerators()
continue;
}

$generator = $this->container->get($name);
try {
$generator = $this->container->get($name);
} catch (\Exception $e) {
echo $name . ' - ' . $e->getMessage() . PHP_EOL;

continue;
}

if (!$generator) {
continue;
Expand Down
1 change: 1 addition & 0 deletions src/Bootstrap/AddServicesCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AddServicesCompilerPass implements CompilerPassInterface

/**
* AddCommandsCompilerPass constructor.
*
* @param string $root
*/
public function __construct($root)
Expand Down
3 changes: 2 additions & 1 deletion src/Bootstrap/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Drupal

/**
* Drupal constructor.
*
* @param $autoload
* @param $root
* @param $appRoot
Expand Down Expand Up @@ -49,7 +50,7 @@ public function boot()
$uri .= '/';
}
$uri .= 'index.php';
$request = Request::create($uri, 'GET', array(), array(), array(), array('SCRIPT_NAME' => $this->appRoot . '/index.php'));
$request = Request::create($uri, 'GET', [], [], [], ['SCRIPT_NAME' => $this->appRoot . '/index.php']);
} else {
$request = Request::createFromGlobals();
}
Expand Down
1 change: 1 addition & 0 deletions src/Bootstrap/DrupalKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

/**
* Class DrupalKernel
*
* @package Drupal\Console\Utils
*/
class DrupalKernel extends DrupalKernelBase
Expand Down
1 change: 1 addition & 0 deletions src/Bootstrap/DrupalServiceModifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class DrupalServiceModifier implements ServiceModifierInterface

/**
* DrupalServiceModifier constructor.
*
* @param string $root
* @param string $serviceTag
* @param string $generatorTag
Expand Down
1 change: 1 addition & 0 deletions src/Bootstrap/FindCommandsCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class FindCommandsCompilerPass implements CompilerPassInterface

/**
* FindCommandsCompilerPass constructor.
*
* @param $serviceTag
*/
public function __construct($serviceTag)
Expand Down
1 change: 1 addition & 0 deletions src/Bootstrap/FindGeneratorsCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class FindGeneratorsCompilerPass implements CompilerPassInterface

/**
* FindCommandsCompilerPass constructor.
*
* @param $serviceTag
*/
public function __construct($serviceTag)
Expand Down
1 change: 1 addition & 0 deletions src/Command/Breakpoints/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class DebugCommand extends Command

/**
* DebugCommand constructor.
*
* @param BreakpointManagerInterface $breakpointManager
* @param string $appRoot
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Cache/RebuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

/**
* Class RebuildCommand
*
* @package Drupal\Console\Command\Cache
*/
class RebuildCommand extends Command
Expand All @@ -43,6 +44,7 @@ class RebuildCommand extends Command

/**
* RebuildCommand constructor.
*
* @param DrupalApi $drupalApi
* @param Site $site
* @param $classLoader
Expand Down
1 change: 1 addition & 0 deletions src/Command/Config/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class DebugCommand extends Command

/**
* DebugCommand constructor.
*
* @param ConfigFactory $configFactory
* @param CachedStorage $configStorage
*/
Expand Down
1 change: 1 addition & 0 deletions src/Command/Config/DeleteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class DeleteCommand extends Command

/**
* DeleteCommand constructor.
*
* @param ConfigFactory $configFactory
* @param CachedStorage $configStorage
* @param FileStorage $configStorageSync
Expand Down
1 change: 1 addition & 0 deletions src/Command/Config/DiffCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class DiffCommand extends Command

/**
* DiffCommand constructor.
*
* @param CachedStorage $configStorage
* @param ConfigManager $configManager
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Command/Config/EditCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class EditCommand extends Command

/**
* EditCommand constructor.
*
* @param ConfigFactory $configFactory
* @param CachedStorage $configStorage
* @param ConfigurationManager $configurationManager
Expand Down Expand Up @@ -110,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!$editor) {
$editor = $this->getEditor();
}
$processBuilder = new ProcessBuilder(array($editor, $configFile));
$processBuilder = new ProcessBuilder([$editor, $configFile]);
$process = $processBuilder->getProcess();
$process->setTty('true');
$process->run();
Expand Down Expand Up @@ -169,7 +170,7 @@ protected function getEditor()
return trim($editor);
}

$processBuilder = new ProcessBuilder(array('bash'));
$processBuilder = new ProcessBuilder(['bash']);
$process = $processBuilder->getProcess();
$process->setCommandLine('echo ${EDITOR:-${VISUAL:-vi}}');
$process->run();
Expand Down
1 change: 1 addition & 0 deletions src/Command/Config/ExportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ExportCommand extends Command

/**
* ExportCommand constructor.
*
* @param ConfigManager $configManager
*/
public function __construct(ConfigManager $configManager)
Expand Down
13 changes: 7 additions & 6 deletions src/Command/Config/ExportContentTypeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ExportContentTypeCommand extends Command

/**
* ExportContentTypeCommand constructor.
*
* @param EntityTypeManagerInterface $entityTypeManager
* @param CachedStorage $configStorage
* @param Manager $extensionManager
Expand Down Expand Up @@ -80,7 +81,7 @@ protected function configure()
$this->trans('commands.config.export.content.type.options.optional-config')
);

$this->configExport = array();
$this->configExport = [];
}

/**
Expand All @@ -102,7 +103,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$contentType = $input->getArgument('content-type');
if (!$contentType) {
$bundles_entities = $this->entityTypeManager->getStorage('node_type')->loadMultiple();
$bundles = array();
$bundles = [];
foreach ($bundles_entities as $entity) {
$bundles[$entity->id()] = $entity->label();
}
Expand Down Expand Up @@ -140,7 +141,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$contentTypeNameConfig = $this->getConfiguration($contentTypeName);

$this->configExport[$contentTypeName] = array('data' => $contentTypeNameConfig, 'optional' => $optionalConfig);
$this->configExport[$contentTypeName] = ['data' => $contentTypeNameConfig, 'optional' => $optionalConfig];

$this->getFields($contentType, $optionalConfig);

Expand All @@ -161,7 +162,7 @@ protected function getFields($contentType, $optional = false)
$field_name_config = $this->getConfiguration($field_name);
// Only select fields related with content type
if ($field_name_config['bundle'] == $contentType) {
$this->configExport[$field_name] = array('data' => $field_name_config, 'optional' => $optional);
$this->configExport[$field_name] = ['data' => $field_name_config, 'optional' => $optional];
// Include dependencies in export files
if ($dependencies = $this->fetchDependencies($field_name_config, 'config')) {
$this->resolveDependencies($dependencies, $optional);
Expand All @@ -179,7 +180,7 @@ protected function getFormDisplays($contentType, $optional = false)
$form_display_name_config = $this->getConfiguration($form_display_name);
// Only select fields related with content type
if ($form_display_name_config['bundle'] == $contentType) {
$this->configExport[$form_display_name] = array('data' => $form_display_name_config, 'optional' => $optional);
$this->configExport[$form_display_name] = ['data' => $form_display_name_config, 'optional' => $optional];
// Include dependencies in export files
if ($dependencies = $this->fetchDependencies($form_display_name_config, 'config')) {
$this->resolveDependencies($dependencies, $optional);
Expand All @@ -197,7 +198,7 @@ protected function getViewDisplays($contentType, $optional = false)
$view_display_name_config = $this->getConfiguration($view_display_name);
// Only select fields related with content type
if ($view_display_name_config['bundle'] == $contentType) {
$this->configExport[$view_display_name] = array('data' => $view_display_name_config, 'optional' => $optional);
$this->configExport[$view_display_name] = ['data' => $view_display_name_config, 'optional' => $optional];
// Include dependencies in export files
if ($dependencies = $this->fetchDependencies($view_display_name_config, 'config')) {
$this->resolveDependencies($dependencies, $optional);
Expand Down
5 changes: 3 additions & 2 deletions src/Command/Config/ExportSingleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ExportSingleCommand extends Command

/**
* ExportSingleCommand constructor.
*
* @param EntityTypeManagerInterface $entityTypeManager
* @param CachedStorage $configStorage
*/
Expand Down Expand Up @@ -118,9 +119,9 @@ function ($definition) {
);

uasort($entity_types, 'strnatcasecmp');
$config_types = array(
$config_types = [
'system.simple' => $this->trans('commands.config.export.single.options.simple-configuration'),
) + $entity_types;
] + $entity_types;

return $config_types;
}
Expand Down
3 changes: 2 additions & 1 deletion src/Command/Config/ExportViewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ExportViewCommand extends Command

/**
* ExportViewCommand constructor.
*
* @param EntityTypeManagerInterface $entityTypeManager
* @param CachedStorage $configStorage
* @param Manager $extensionManager
Expand Down Expand Up @@ -156,7 +157,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$viewNameConfig = $this->getConfiguration($viewTypeName);

$this->configExport[$viewTypeName] = array('data' => $viewNameConfig, 'optional' => $optionalConfig);
$this->configExport[$viewTypeName] = ['data' => $viewNameConfig, 'optional' => $optionalConfig];

// Include config dependencies in export files
if ($dependencies = $this->fetchDependencies($viewNameConfig, 'config')) {
Expand Down
1 change: 1 addition & 0 deletions src/Command/Config/ImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ImportCommand extends Command

/**
* ImportCommand constructor.
*
* @param CachedStorage $configStorage
* @param ConfigManager $configManager
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Command/Config/ImportSingleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class ImportSingleCommand extends Command

/**
* ImportSingleCommand constructor.
*
* @param CachedStorage $configStorage
* @param ConfigManager $configManager
*/
Expand Down Expand Up @@ -158,7 +159,7 @@ private function configImport($io, StorageComparer $storageComparer)
$sync_steps = $configImporter->initialize();

foreach ($sync_steps as $step) {
$context = array();
$context = [];
do {
$configImporter->doSyncStep($step, $context);
} while ($context['finished'] < 1);
Expand Down
1 change: 1 addition & 0 deletions src/Command/Config/OverrideCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class OverrideCommand extends Command

/**
* OverrideCommand constructor.
*
* @param CachedStorage $configStorage
* @param ConfigFactory $configFactory
*/
Expand Down
2 changes: 2 additions & 0 deletions src/Command/Config/SettingsDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/**
* Class DebugCommand
*
* @package Drupal\Console\Command\Config
*/
class SettingsDebugCommand extends Command
Expand All @@ -30,6 +31,7 @@ class SettingsDebugCommand extends Command

/**
* SettingsDebugCommand constructor.
*
* @param Settings $settings
*/
public function __construct(Settings $settings)
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Config/ValidateDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private function manualCheckConfigSchema(TypedConfigManagerInterface $typed_conf
{
$data_definition = $typed_config->buildDataDefinition($config_schema, $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));
}
Expand Down
1 change: 1 addition & 0 deletions src/Command/ContainerDebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

/**
* Class ContainerDebugCommand
*
* @package Drupal\Console\Command
*/
class ContainerDebugCommand extends Command
Expand Down
4 changes: 3 additions & 1 deletion src/Command/Create/CommentsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

/**
* Class CommentsCommand
*
* @package Drupal\Console\Command\Generate
*/
class CommentsCommand extends Command
Expand All @@ -31,6 +32,7 @@ class CommentsCommand extends Command

/**
* CommentsCommand constructor.
*
* @param CommentData $createCommentData
*/
public function __construct(CommentData $createCommentData)
Expand Down Expand Up @@ -116,7 +118,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
array_values($timeRanges)
);

$input->setOption('time-range', array_search($timeRange, $timeRanges));
$input->setOption('time-range', array_search($timeRange, $timeRanges));
}
}

Expand Down
Loading