Skip to content

Commit

Permalink
[console] Apply PSR-2 code style. (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas committed Jan 7, 2018
1 parent 9dd5350 commit 8bc9d40
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 32 deletions.
10 changes: 8 additions & 2 deletions src/Bootstrap/DrupalInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@

namespace Drupal\Console\Core\Bootstrap;

use Drupal\Console\Core\Utils\ConfigurationManager;
use Drupal\Console\Core\Utils\DrupalFinder;

interface DrupalInterface {
public function __construct($autoload, DrupalFinder $drupalFinder);
interface DrupalInterface
{
public function __construct(
$autoload,
DrupalFinder $drupalFinder,
ConfigurationManager $configurationManager
);

public function boot();
}
1 change: 1 addition & 0 deletions src/Command/AboutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

/**
* Class AboutCommand
*
* @package Drupal\Console\Core\Command
*/
class AboutCommand extends Command
Expand Down
5 changes: 3 additions & 2 deletions src/Command/Chain/ChainCustomCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ public function __construct(
$name,
$description,
$placeHolders,
$file)
{
$file
) {

$this->name = $name;
$this->description = $description;
$this->file = $file;
Expand Down
4 changes: 3 additions & 1 deletion src/Command/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

/**
* Class Command
*
* @package Drupal\Console\Core\Command
*/
abstract class Command extends BaseCommand
Expand All @@ -37,7 +38,8 @@ protected function initialize(InputInterface $input, OutputInterface $output)
/**
* @return \Drupal\Console\Core\Style\DrupalStyle
*/
public function getIo() {
public function getIo()
{
return $this->io;
}
}
1 change: 1 addition & 0 deletions src/Command/ContainerAwareCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

/**
* Class ContainerAwareCommand
*
* @package Drupal\Console\Core\Command
*/
abstract class ContainerAwareCommand extends Command
Expand Down
25 changes: 12 additions & 13 deletions src/Command/Shared/CommandTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,20 @@ public function getDescription()
return parent::getDescription();
}

/**
/**
* @inheritdoc
*/
public function getHelp()
{
$help = sprintf(
'commands.%s.help',
str_replace(':', '.', $this->getName())
);

if (parent::getHelp()==$help) {
return $this->trans($help);
}
public function getHelp()
{
$help = sprintf(
'commands.%s.help',
str_replace(':', '.', $this->getName())
);

return parent::getHelp();
}
if (parent::getHelp()==$help) {
return $this->trans($help);
}

return parent::getHelp();
}
}
2 changes: 1 addition & 1 deletion src/Descriptor/TextDescriptor.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ protected function describeApplication(Application $application, array $options
}

$spacingWidth = $width - strlen($name.$alias);
if($spacingWidth < 0) {
if ($spacingWidth < 0) {
$spacingWidth = 0;
}

Expand Down
3 changes: 1 addition & 2 deletions src/EventSubscriber/ShowGenerateCountCodeLinesListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class ShowGenerateCountCodeLinesListener implements EventSubscriberInterface
*
* @param TranslatorManagerInterface $translator
*
* @param CountCodeLines $countCodeLines
*
* @param CountCodeLines $countCodeLines
*/
public function __construct(
TranslatorManagerInterface $translator,
Expand Down
2 changes: 1 addition & 1 deletion src/Generator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function renderFile(
$flag = null
) {
if (!is_dir(dirname($target))) {
if(!mkdir(dirname($target), 0777, true)){
if (!mkdir(dirname($target), 0777, true)) {
throw new \InvalidArgumentException(
sprintf(
'Path "%s" is invalid. You need to provide a valid path.',
Expand Down
6 changes: 5 additions & 1 deletion src/Style/DrupalStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ public function askHiddenEmpty($question)
public function askEmpty($question, $validator = null)
{
$question = new Question($question, '');
$question->setValidator(function ($answer) { return $answer; });
$question->setValidator(
function ($answer) {
return $answer;
}
);

return trim($this->askQuestion($question));
}
Expand Down
3 changes: 2 additions & 1 deletion src/Utils/ChainDiscovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ public function extractEnvironmentPlaceHolders($chainContent)
return $this->extractPlaceHolders($chainContent, '$');
}

public function extractVars($chainContent) {
public function extractVars($chainContent)
{
$chain = Yaml::parse($chainContent);
if (!array_key_exists('vars', $chain)) {
return [];
Expand Down
3 changes: 2 additions & 1 deletion src/Utils/ConfigurationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@ public function getSites()
/**
* @return array
*/
public function getConfigurationFiles() {
public function getConfigurationFiles()
{
return $this->configurationFiles;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Utils/DrupalFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ protected function defineConstants($vendorDir)

if (!defined("DRUPAL_CONSOLE_LIBRARY")) {
define(
"DRUPAL_CONSOLE_LIBRARY",
"/{$vendorDir}/drupal/%s/console/translations/%s"
"DRUPAL_CONSOLE_LIBRARY",
"/{$vendorDir}/drupal/%s/console/translations/%s"
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/FileQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FileQueue
/**
* FileQueue constructor.
*
* @param string $appRoot
* @param string $appRoot
*/
public function __construct($appRoot)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Utils/MessageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ public function getMessages()
return $this->messages;
}

public function remove($removeBy = null) {
public function remove($removeBy = null)
{
$this->messages = array_filter(
$this->messages,
function ($message) use ($removeBy) {
function ($message) use ($removeBy) {
if (is_null($message['removableBy'])) {

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Utils/NestedArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static function replaceKey(array &$array, array $parents, $new_key)
/**
* @param $array1
* @param $array2
* @param bool $negate if Negate is true only if values are equal are returned.
* @param bool $negate if Negate is true only if values are equal are returned.
* @param $statistics mixed array
* @return array
*/
Expand Down

0 comments on commit 8bc9d40

Please sign in to comment.