Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.

Commit 8513e35

Browse files
committed
Merge pull request #17 from mmoreram/feature/updated-dependencies
Updated PHPUnit dependencies
2 parents ea081e8 + 273f381 commit 8513e35

19 files changed

+159
-190
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/vendor
2-
/bin/phpunit
2+
/bin/*
3+
!/bin/compile
4+
!/bin/php-formatter
35
composer.phar
46
composer.lock
57
phpunit.xml

.php_cs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
return Symfony\CS\Config\Config::create()
4+
// use SYMFONY_LEVEL:
5+
->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL)
6+
// and extra fixers:
7+
->fixers(array(
8+
'concat_with_spaces',
9+
'multiline_spaces_before_semicolon',
10+
'short_array_syntax',
11+
'-remove_lines_between_uses'
12+
))
13+
->finder(
14+
Symfony\CS\Finder\DefaultFinder::create()
15+
->in('src/')
16+
->in('tests/')
17+
)
18+
;

bin/php-formatter

100755100644
File mode changed.

build/php-formatter.phar

100644100755
125 KB
Binary file not shown.

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"symfony/property-access": "~2.2"
2424
},
2525
"require-dev": {
26-
"phpunit/phpunit": ">=3.7"
26+
"fabpot/php-cs-fixer": "1.4.2",
27+
"phpunit/phpunit": "4.5.0"
2728
},
2829
"bin": [
2930
"bin/php-formatter"

src/PHPFormatter/Command/HeaderCommand.php

-9
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
101101
);
102102

103103
if (empty($header)) {
104-
105104
throw new Exception('Header definition must be defined in .formatter.yml file under');
106105
}
107106

@@ -114,20 +113,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
114113
}
115114

116115
if (!is_file($path) && !is_dir($path)) {
117-
118116
throw new Exception('Directory or file "' . $path . '" does not exist');
119117
}
120118

121119
/**
122120
* Dry-run message
123121
*/
124122
if ($dryRun && $verbose >= OutputInterface::VERBOSITY_VERBOSE) {
125-
126123
$output->writeln('# This process has been executed in mode dry-run');
127124
}
128125

129126
if ($verbose >= OutputInterface::VERBOSITY_VERBOSE) {
130-
131127
$output->writeln('# Executing process in ' . $path);
132128
}
133129

@@ -143,7 +139,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
143139
* file data, if is not empty.
144140
*/
145141
if ($verbose >= OutputInterface::VERBOSITY_VERBOSE) {
146-
147142
$output->writeln("# Header used:\n\n" . $header);
148143
}
149144

@@ -153,22 +148,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
153148
* Each found php file is processed
154149
*/
155150
foreach ($files as $file) {
156-
157151
$data = file_get_contents($file);
158152
$result = $headerFixer->fix($data);
159153

160154
if ($result === false || $data === $result) {
161-
162155
continue;
163156
}
164157

165158
if ($verbose >= OutputInterface::VERBOSITY_NORMAL) {
166-
167159
$output->writeln('# ' . $file);
168160
}
169161

170162
if (!$dryRun) {
171-
172163
file_put_contents($file, $result);
173164
}
174165
}

src/PHPFormatter/Command/UseSortCommand.php

+10-27
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
127127
}
128128

129129
if (!is_file($path) && !is_dir($path)) {
130-
131130
throw new Exception('Directory or file "' . $path . '" does not exist');
132131
}
133132

@@ -185,20 +184,20 @@ private function getUsableConfig(InputInterface $input)
185184
return $configLoader->loadConfigValues(
186185
self::COMMAND_NAME,
187186
$configFinder->findConfigFile($configPath),
188-
array(
187+
[
189188
'group' => $input->getOption('group'),
190189
'group-type' => $input->getOption('group-type'),
191190
'group-skip-empty' => $input->getOption('group-skip-empty'),
192191
'sort-type' => $input->getOption('sort-type'),
193-
'sort-direction' => $input->getOption('sort-direction')
194-
),
195-
array(
196-
'group' => array('_main'),
192+
'sort-direction' => $input->getOption('sort-direction'),
193+
],
194+
[
195+
'group' => ['_main'],
197196
'group-type' => UseSorter::GROUP_TYPE_EACH,
198197
'group-skip-empty' => false,
199198
'sort-type' => UseSorter::SORT_TYPE_ALPHABETIC,
200-
'sort-direction' => UseSorter::SORT_DIRECTION_ASC
201-
)
199+
'sort-direction' => UseSorter::SORT_DIRECTION_ASC,
200+
]
202201
);
203202
}
204203

@@ -215,21 +214,18 @@ private function printDryRunMessage(
215214
InputInterface $input,
216215
OutputInterface $output,
217216
$path
218-
)
219-
{
217+
) {
220218
$dryRun = $input->getOption('dry-run');
221219
$verbose = $output->getVerbosity();
222220

223221
/**
224222
* Dry-run message
225223
*/
226224
if ($dryRun && $verbose >= OutputInterface::VERBOSITY_VERBOSE) {
227-
228225
$output->writeln('# This process has been executed in mode dry-run');
229226
}
230227

231228
if ($verbose >= OutputInterface::VERBOSITY_VERBOSE) {
232-
233229
$output->writeln('# Executing process in ' . $path);
234230
}
235231

@@ -247,42 +243,34 @@ private function printDryRunMessage(
247243
private function printConfigUsed(
248244
OutputInterface $output,
249245
array $options
250-
)
251-
{
246+
) {
252247
$verbose = $output->getVerbosity();
253248

254249
/**
255250
* If verbose level is higher or equal than -vv, we print the config
256251
* file data, if is not empty.
257252
*/
258253
if ($verbose >= OutputInterface::VERBOSITY_VERBOSE) {
259-
260254
$output->writeln('# Executing process with this configuration');
261255
if (!empty($options['group'])) {
262-
263256
foreach ($options['group'] as $group) {
264-
265257
$output->writeln('# --group="' . $group . '"');
266258
}
267259
}
268260

269261
if (!empty($options['group-type'])) {
270-
271262
$output->writeln('# --group-type="' . $options['group-type'] . '"');
272263
}
273264

274265
if (!empty($options['group-skip-empty'])) {
275-
276266
$output->writeln('# --group-skip-empty="' . $options['group-skip-empty'] . '"');
277267
}
278268

279269
if (!empty($options['sort-type'])) {
280-
281270
$output->writeln('# --sort-type="' . $options['sort-type'] . '"');
282271
}
283272

284273
if (!empty($options['sort-direction'])) {
285-
286274
$output->writeln('# --sort-direction="' . $options['sort-direction'] . '"');
287275
}
288276
}
@@ -308,8 +296,7 @@ private function parseAndFixFiles(
308296
IteratorAggregate $files,
309297
array $options
310298

311-
)
312-
{
299+
) {
313300
$dryRun = $input->getOption('dry-run');
314301
$verbose = $output->getVerbosity();
315302
$useSorter = $this->createUseSorter($options);
@@ -318,22 +305,18 @@ private function parseAndFixFiles(
318305
* Each found php file is processed
319306
*/
320307
foreach ($files as $file) {
321-
322308
$data = file_get_contents($file);
323309
$result = $useSorter->sort($data);
324310

325311
if ($result === false || $data === $result) {
326-
327312
continue;
328313
}
329314

330315
if ($verbose >= OutputInterface::VERBOSITY_NORMAL) {
331-
332316
$output->writeln('# ' . $file);
333317
}
334318

335319
if (!$dryRun) {
336-
337320
file_put_contents($file, $result);
338321
}
339322
}

src/PHPFormatter/Compiler/Compiler.php

+2-6
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ protected function addFile(
9090
Phar $phar,
9191
SplFileInfo $file,
9292
$strip = true
93-
)
94-
{
93+
) {
9594
$path = strtr(str_replace(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR, '', $file->getRealPath()), '\\', '/');
9695
$content = file_get_contents($file);
9796
if ($strip) {
@@ -143,7 +142,7 @@ protected function stripWhitespace($source)
143142
foreach (token_get_all($source) as $token) {
144143
if (is_string($token)) {
145144
$output .= $token;
146-
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
145+
} elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
147146
$output .= str_repeat("\n", substr_count($token[1], "\n"));
148147
} elseif (T_WHITESPACE === $token[0]) {
149148
// reduce wide spaces
@@ -213,7 +212,6 @@ private function addPHPFiles(Phar $phar)
213212
->in(realpath(__DIR__ . '/../../../src'));
214213

215214
foreach ($finder as $file) {
216-
217215
$this->addFile($phar, $file);
218216
}
219217

@@ -243,7 +241,6 @@ private function addVendorFiles(Phar $phar)
243241
->in(realpath($vendorPath . 'symfony/'));
244242

245243
foreach ($finder as $file) {
246-
247244
$this->addFile($phar, $file);
248245
}
249246

@@ -273,7 +270,6 @@ private function addComposerVendorFiles(Phar $phar)
273270
->addFile($phar, new \SplFileInfo($vendorPath . 'composer/ClassLoader.php'));
274271

275272
if (file_exists($vendorPath . 'composer/include_paths.php')) {
276-
277273
$this->addFile($phar, new \SplFileInfo($vendorPath . 'composer/include_paths.php'));
278274
}
279275

src/PHPFormatter/Finder/ConfigFinder.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@ class ConfigFinder
3434
public function findConfigFile($path)
3535
{
3636
$configFilePath = rtrim($path, '/') . '/' . PHPFormatter::CONFIG_FILE_NAME;
37-
$config = array();
37+
$config = [];
3838
if (is_file($configFilePath)) {
39-
4039
$yamlParser = new YamlParser();
4140
$config = $yamlParser->parse(file_get_contents($configFilePath));
4241
}
4342

4443
return $config;
4544
}
46-
4745
}

src/PHPFormatter/Loader/ConfigLoader.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ class ConfigLoader
3939
public function loadConfigValues(
4040
$commandName,
4141
array $configValues,
42-
array $commandValues = array(),
43-
array $defaultValues = array()
44-
)
45-
{
42+
array $commandValues = [],
43+
array $defaultValues = []
44+
) {
4645
$configValues = isset($configValues[$commandName]) && is_array($configValues[$commandName])
4746
? $configValues[$commandName]
48-
: array();
47+
: [];
4948

5049
return array_merge(
5150
$defaultValues,
@@ -75,8 +74,7 @@ public function loadConfigValue(
7574
array $configValues,
7675
array $commandValue = null,
7776
array $defaultValue = null
78-
)
79-
{
77+
) {
8078
return isset($configValues[$commandName])
8179
? $configValues[$commandName]
8280
: $commandValue

0 commit comments

Comments
 (0)