Skip to content

Commit 419bb11

Browse files
authored
CS Fixer (#1243)
* CS Fixer
1 parent 395bb11 commit 419bb11

40 files changed

+470
-427
lines changed

.php_cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$finder = PhpCsFixer\Finder::create()
4+
->exclude('vendor')
5+
->in(__DIR__)
6+
;
7+
8+
return PhpCsFixer\Config::create()
9+
->setRules([
10+
'@Symfony' => true,
11+
'full_opening_tag' => false,
12+
'yoda_style' => false,
13+
'array_syntax' => ['syntax' => 'short'],
14+
])
15+
->setFinder($finder)
16+
;

Command/BaseBootstrapSymlinkCommand.php

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
use Symfony\Component\Filesystem\Filesystem;
2222

2323
/**
24-
* Command to check and create bootstrap symlink into MopaBootstrapBundle
24+
* Command to check and create bootstrap symlink into MopaBootstrapBundle.
2525
*
2626
* @author phiamo <[email protected]>
2727
*/
2828
abstract class BaseBootstrapSymlinkCommand extends ContainerAwareCommand
2929
{
30-
public static $mopaBootstrapBundleName = "mopa/bootstrap-bundle";
30+
public static $mopaBootstrapBundleName = 'mopa/bootstrap-bundle';
3131
public static $targetSuffix = '';
3232
public static $pathName = 'TwitterBootstrap';
3333
/**
@@ -42,19 +42,19 @@ abstract class BaseBootstrapSymlinkCommand extends ContainerAwareCommand
4242
/**
4343
* Checks symlink's existence.
4444
*
45-
* @param string $symlinkTarget The Target
46-
* @param string $symlinkName The Name
47-
* @param boolean $forceSymlink Force to be a link or throw exception
45+
* @param string $symlinkTarget The Target
46+
* @param string $symlinkName The Name
47+
* @param bool $forceSymlink Force to be a link or throw exception
4848
*
49-
* @return boolean
49+
* @return bool
5050
*
5151
* @throws \Exception
5252
*/
5353
public static function checkSymlink($symlinkTarget, $symlinkName, $forceSymlink = false)
5454
{
5555
if ($forceSymlink && file_exists($symlinkName) && !is_link($symlinkName)) {
56-
if ("link" != filetype($symlinkName)) {
57-
throw new \Exception($symlinkName." exists and is no link!");
56+
if ('link' != filetype($symlinkName)) {
57+
throw new \Exception($symlinkName.' exists and is no link!');
5858
}
5959
} elseif (is_link($symlinkName)) {
6060
$linkTarget = readlink($symlinkName);
@@ -88,7 +88,7 @@ public static function checkSymlink($symlinkTarget, $symlinkName, $forceSymlink
8888
public static function createSymlink($symlinkTarget, $symlinkName)
8989
{
9090
if (false === @symlink($symlinkTarget, $symlinkName)) {
91-
throw new \Exception("An error occurred while creating symlink".$symlinkName);
91+
throw new \Exception('An error occurred while creating symlink'.$symlinkName);
9292
}
9393
if (false === $target = readlink($symlinkName)) {
9494
throw new \Exception("Symlink $symlinkName points to target $target");
@@ -106,18 +106,18 @@ public static function createSymlink($symlinkTarget, $symlinkName)
106106
public static function createMirror($symlinkTarget, $symlinkName)
107107
{
108108
if (strlen($symlinkTarget) == 0 || empty($symlinkTarget)) {
109-
throw new \Exception("symlinkTarget empty!".var_export($symlinkTarget, true));
109+
throw new \Exception('symlinkTarget empty!'.var_export($symlinkTarget, true));
110110
}
111111
if (strlen($symlinkName) == 0 || empty($symlinkName)) {
112-
throw new \Exception("symlinkName empty!".var_export($symlinkName, true));
112+
throw new \Exception('symlinkName empty!'.var_export($symlinkName, true));
113113
}
114114
$filesystem = new Filesystem();
115115
$filesystem->mkdir($symlinkName);
116116
$filesystem->mirror(
117117
$symlinkName.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$symlinkTarget,
118118
$symlinkName,
119119
null,
120-
array('copy_on_windows' => true, 'delete' => true, 'override' => true)
120+
['copy_on_windows' => true, 'delete' => true, 'override' => true]
121121
);
122122
}
123123

@@ -127,7 +127,7 @@ public static function createMirror($symlinkTarget, $symlinkName)
127127
protected function configure()
128128
{
129129
$this
130-
->setDescription("Check and if possible install symlink to ".static::$targetSuffix)
130+
->setDescription('Check and if possible install symlink to '.static::$targetSuffix)
131131
->addArgument('pathTo'.static::$pathName, InputArgument::OPTIONAL, 'Where is twitters/bootstrap located?')
132132
->addArgument('pathToMopaBootstrapBundle', InputArgument::OPTIONAL, 'Where is MopaBootstrapBundle located?')
133133
->addOption('force', 'f', InputOption::VALUE_NONE, 'Force rewrite of existing symlink if possible!')
@@ -137,7 +137,7 @@ protected function configure()
137137
}
138138

139139
/**
140-
* Get Package involved
140+
* Get Package involved.
141141
*
142142
* @return string Name of twbs package
143143
*/
@@ -154,46 +154,46 @@ protected function execute(InputInterface $input, OutputInterface $output)
154154
if ($input->getOption('manual')) {
155155
list($symlinkTarget, $symlinkName) = $this->getBootstrapPathsFromUser();
156156
} elseif (false !== $composer = ComposerAdapter::getComposer($input, $output)) {
157-
$targetPath = $this->getContainer()->getParameter("mopa_bootstrap.bootstrap.install_path");
157+
$targetPath = $this->getContainer()->getParameter('mopa_bootstrap.bootstrap.install_path');
158158
$cmanager = new ComposerPathFinder($composer);
159-
$options = array(
159+
$options = [
160160
'targetSuffix' => DIRECTORY_SEPARATOR.$targetPath.static::$targetSuffix,
161161
'sourcePrefix' => '..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR,
162-
);
162+
];
163163
list($symlinkTarget, $symlinkName) = $cmanager->getSymlinkFromComposer(
164164
self::$mopaBootstrapBundleName,
165165
$this->getTwitterBootstrapName(),
166166
$options
167167
);
168168
} else {
169-
$this->output->writeln("<error>Could not find composer and manual option not specified!</error>");
169+
$this->output->writeln('<error>Could not find composer and manual option not specified!</error>');
170170

171171
return;
172172
}
173173

174174
// Automatically detect if on Win XP where symlink will allways fail
175-
if ($input->getOption('no-symlink') || PHP_OS == "WINNT") {
176-
$this->output->write("Checking destination");
175+
if ($input->getOption('no-symlink') || PHP_OS == 'WINNT') {
176+
$this->output->write('Checking destination');
177177

178178
if (true === self::checkSymlink($symlinkTarget, $symlinkName)) {
179-
$this->output->writeln(" ... <comment>symlink already exists</comment>");
179+
$this->output->writeln(' ... <comment>symlink already exists</comment>');
180180
} else {
181-
$this->output->writeln(" ... <comment>not existing</comment>");
182-
$this->output->writeln(sprintf("Mirroring to: %s", $symlinkName));
183-
$this->output->write(sprintf("from target: %s", realpath($symlinkName.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$symlinkTarget)));
181+
$this->output->writeln(' ... <comment>not existing</comment>');
182+
$this->output->writeln(sprintf('Mirroring to: %s', $symlinkName));
183+
$this->output->write(sprintf('from target: %s', realpath($symlinkName.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$symlinkTarget)));
184184
self::createMirror($symlinkTarget, $symlinkName);
185185
}
186186
} else {
187-
$this->output->write("Checking symlink");
187+
$this->output->write('Checking symlink');
188188
if (false === self::checkSymlink($symlinkTarget, $symlinkName, true)) {
189-
$this->output->writeln(" ... <comment>not existing</comment>");
190-
$this->output->writeln("Creating symlink: ".$symlinkName);
191-
$this->output->write("for target: ".$symlinkTarget);
189+
$this->output->writeln(' ... <comment>not existing</comment>');
190+
$this->output->writeln('Creating symlink: '.$symlinkName);
191+
$this->output->write('for target: '.$symlinkTarget);
192192
self::createSymlink($symlinkTarget, $symlinkName);
193193
}
194194
}
195195

196-
$this->output->writeln(" ... <info>OK</info>");
196+
$this->output->writeln(' ... <info>OK</info>');
197197
}
198198

199199
protected function getBootstrapPathsFromUser()
@@ -202,28 +202,28 @@ protected function getBootstrapPathsFromUser()
202202
$symlinkName = $this->input->getArgument('pathToMopaBootstrapBundle');
203203

204204
if (empty($symlinkName)) {
205-
throw new \Exception("pathToMopaBootstrapBundle not specified");
205+
throw new \Exception('pathToMopaBootstrapBundle not specified');
206206
}
207207

208208
if (!is_dir(dirname($symlinkName))) {
209-
throw new \Exception("pathToMopaBootstrapBundle: ".dirname($symlinkName)." does not exist");
209+
throw new \Exception('pathToMopaBootstrapBundle: '.dirname($symlinkName).' does not exist');
210210
}
211211

212212
if (empty($symlinkTarget)) {
213-
throw new \Exception(static::$pathName." not specified");
213+
throw new \Exception(static::$pathName.' not specified');
214214
}
215215

216-
if (substr($symlinkTarget, 0, 1) == "/") {
217-
$this->output->writeln("<comment>Try avoiding absolute paths, for portability!</comment>");
216+
if (substr($symlinkTarget, 0, 1) == '/') {
217+
$this->output->writeln('<comment>Try avoiding absolute paths, for portability!</comment>');
218218
if (!is_dir($symlinkTarget)) {
219-
throw new \Exception("Target path ".$symlinkTarget."is not a directory!");
219+
throw new \Exception('Target path '.$symlinkTarget.'is not a directory!');
220220
}
221221
} else {
222-
$symlinkTarget = $symlinkName.DIRECTORY_SEPARATOR."..".DIRECTORY_SEPARATOR.$symlinkTarget;
222+
$symlinkTarget = $symlinkName.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$symlinkTarget;
223223
}
224224

225225
if (!is_dir($symlinkTarget)) {
226-
throw new \Exception(static::$pathName." would resolve to: ".$symlinkTarget."\n and this is not reachable from \npathToMopaBootstrapBundle: ".dirname($symlinkName));
226+
throw new \Exception(static::$pathName.' would resolve to: '.$symlinkTarget."\n and this is not reachable from \npathToMopaBootstrapBundle: ".dirname($symlinkName));
227227
}
228228

229229
$dialog = $this->getHelperSet()->get('dialog');
@@ -232,16 +232,16 @@ protected function getBootstrapPathsFromUser()
232232
Pointing to: $symlinkTarget
233233
EOF
234234
;
235-
$this->output->writeln(array(
235+
$this->output->writeln([
236236
'',
237237
$this->getHelperSet()->get('formatter')->formatBlock($text, 'bg=blue;fg=white', true),
238238
'',
239-
));
239+
]);
240240

241241
if ($this->input->isInteractive() && !$dialog->askConfirmation($this->output, '<question>Should this link be created? (y/n)</question>', false)) {
242-
throw new \Exception("Aborting due to User not cofirming!");
242+
throw new \Exception('Aborting due to User not cofirming!');
243243
}
244244

245-
return array($symlinkTarget, $symlinkName);
245+
return [$symlinkTarget, $symlinkName];
246246
}
247247
}

Command/BootstrapSymlinkLessCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717
class BootstrapSymlinkLessCommand extends BaseBootstrapSymlinkCommand
1818
{
19-
public static $mopaBootstrapBundleName = "mopa/bootstrap-bundle";
20-
public static $twitterBootstrapName = "twbs/bootstrap";
19+
public static $mopaBootstrapBundleName = 'mopa/bootstrap-bundle';
20+
public static $twitterBootstrapName = 'twbs/bootstrap';
2121

2222
protected function getTwitterBootstrapName()
2323
{
@@ -30,7 +30,8 @@ protected function configure()
3030

3131
$this
3232
->setName('mopa:bootstrap:symlink:less')
33-
->setHelp(<<<EOT
33+
->setHelp(
34+
<<<EOT
3435
The <info>mopa:bootstrap:symlink:less</info> command helps you checking and symlinking/mirroring the twitters/bootstrap library.
3536
3637
By default, the command uses composer to retrieve the paths of MopaBootstrapBundle and twbs/bootstrap in your vendors.

Command/BootstrapSymlinkSassCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
class BootstrapSymlinkSassCommand extends BaseBootstrapSymlinkCommand
1818
{
19-
public static $twitterBootstrapName = "twbs/bootstrap-sass";
19+
public static $twitterBootstrapName = 'twbs/bootstrap-sass';
2020
public static $targetSuffix = '-sass';
2121
public static $pathName = 'TwitterBootstrapSass';
2222

@@ -31,7 +31,8 @@ protected function configure()
3131

3232
$this
3333
->setName('mopa:bootstrap:symlink:sass')
34-
->setHelp(<<<EOT
34+
->setHelp(
35+
<<<EOT
3536
The <info>mopa:bootstrap:symlink:sass</info> command helps you checking and symlinking/mirroring the twbs/bootstrap-sass library.
3637
3738
By default, the command uses composer to retrieve the paths of MopaBootstrapBundle and twbs/bootstrap-sass in your vendors.

Command/InstallFontCommand.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
*/
2525
class InstallFontCommand extends ContainerAwareCommand
2626
{
27-
public static $iconSetsPaths = array(
28-
"glyphicons" => "fonts/bootstrap",
29-
"fontawesome" => "fonts/fa",
30-
"fontawesome4" => "fonts/fa4",
31-
"zmdi" => "fonts/zmdi",
32-
);
27+
public static $iconSetsPaths = [
28+
'glyphicons' => 'fonts/bootstrap',
29+
'fontawesome' => 'fonts/fa',
30+
'fontawesome4' => 'fonts/fa4',
31+
'zmdi' => 'fonts/zmdi',
32+
];
3333

3434
/**
3535
* {@inheritdoc}
@@ -38,8 +38,9 @@ protected function configure()
3838
{
3939
$this
4040
->setName('mopa:bootstrap:install:font')
41-
->setDescription("Install font to web/fonts")
42-
->setHelp(<<<EOT
41+
->setDescription('Install font to web/fonts')
42+
->setHelp(
43+
<<<EOT
4344
The <info>mopa:bootstrap:install:font</info> command install the font configured to used into web/fonts directory
4445
4546
EOT
@@ -57,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5758

5859
$webPath = $this->getContainer()->get('kernel')->getRootDir().DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'web';
5960

60-
$iconWebPath = $webPath.DIRECTORY_SEPARATOR."fonts";
61+
$iconWebPath = $webPath.DIRECTORY_SEPARATOR.'fonts';
6162

6263
$fs = new Filesystem();
6364

@@ -73,15 +74,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
7374

7475
$bsbPath = $composer->getInstallationManager()->getInstallPath($sourcePackage);
7576

76-
$iconSetPath = $bsbPath.DIRECTORY_SEPARATOR."Resources".DIRECTORY_SEPARATOR."public".DIRECTORY_SEPARATOR.self::$iconSetsPaths[$iconSet];
77+
$iconSetPath = $bsbPath.DIRECTORY_SEPARATOR.'Resources'.DIRECTORY_SEPARATOR.'public'.DIRECTORY_SEPARATOR.self::$iconSetsPaths[$iconSet];
7778

7879
$finder->files()->in($iconSetPath);
7980

8081
foreach ($finder as $file) {
8182
$fs->copy($file->getRealpath(), $iconWebPath.DIRECTORY_SEPARATOR.$file->getRelativePathname());
8283
}
8384

84-
$output->writeln("Font: ".$iconSet." Installed... <info>OK</info>");
85+
$output->writeln('Font: '.$iconSet.' Installed... <info>OK</info>');
8586
}
8687

8788
public static function installFonts()

0 commit comments

Comments
 (0)