Skip to content

Commit d2eecf3

Browse files
committed
Fix small issues
1 parent 12d335d commit d2eecf3

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

doc/tasks/phplint.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ parameters:
99
phplint:
1010
exclude: []
1111
jobs: ~
12-
triggered_by: ['php']
12+
triggered_by: ['php', 'phtml', 'php3', 'php4', 'php5']
1313
```
1414
**exclude**
1515
@@ -28,6 +28,6 @@ defaults to 10.
2828
2929
**trigered_by**
3030
31-
*Default: ['php']*
31+
*Default: ['php', 'phtml', 'php3', 'php4', 'php5']*
3232
3333
Any file extensions that you wish to be passed to the linter.

spec/GrumPHP/Collection/ProcessArgumentsCollectionSpec.php

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ function it_should_be_able_to_add_optional_argument()
3434
$this->getValues()->shouldBe(array('--argument=value'));
3535
}
3636

37+
function it_should_be_able_to_add_optional_argument_with_separated_value()
38+
{
39+
$this->addOptionalArgumentWithSeparatedValue('--argument', null);
40+
$this->getValues()->shouldBe(array());
41+
42+
$this->addOptionalArgumentWithSeparatedValue('--argument', 'value');
43+
$this->getValues()->shouldBe(array('--argument', 'value'));
44+
}
45+
3746
function it_should_be_able_to_add_optional_comma_separated_argument()
3847
{
3948
$this->addOptionalCommaSeparatedArgument('--argument=%s', array());

spec/GrumPHP/Task/PHPLintSpec.php renamed to spec/GrumPHP/Task/PhpLintSpec.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Finder\SplFileInfo;
1515
use Symfony\Component\Process\Process;
1616

17-
class PHPLintSpec extends ObjectBehavior
17+
class PhpLintSpec extends ObjectBehavior
1818
{
1919

2020
function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, ProcessFormatterInterface $formatter)
@@ -25,7 +25,7 @@ function let(GrumPHP $grumPHP, ProcessBuilder $processBuilder, ProcessFormatterI
2525

2626
function it_is_initializable()
2727
{
28-
$this->shouldHaveType('GrumPHP\Task\PHPLint');
28+
$this->shouldHaveType('GrumPHP\Task\PhpLint');
2929
}
3030

3131
function it_should_have_a_name()

src/GrumPHP/Collection/ProcessArgumentsCollection.php

+14
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ public function addOptionalArgument($argument, $value)
3535
$this->add(sprintf($argument, $value));
3636
}
3737

38+
/**
39+
* @param string $argument
40+
* @param string $value
41+
*/
42+
public function addOptionalArgumentWithSeparatedValue($argument, $value)
43+
{
44+
if (!$value) {
45+
return;
46+
}
47+
48+
$this->add($argument);
49+
$this->add($value);
50+
}
51+
3852
/**
3953
* @param string $argument
4054
* @param array $values

src/GrumPHP/Task/PHPLint.php renamed to src/GrumPHP/Task/PhpLint.php

+8-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* PHP parallel lint task.
1414
*/
15-
class PHPLint extends AbstractExternalTask
15+
class PhpLint extends AbstractExternalTask
1616
{
1717
/**
1818
* @return string
@@ -31,7 +31,7 @@ public function getConfigurableOptions()
3131
$resolver->setDefaults(array(
3232
'jobs' => null,
3333
'exclude' => array(),
34-
'triggered_by' => array('php'),
34+
'triggered_by' => array('php', 'phtml', 'php3', 'php4', 'php5'),
3535
));
3636

3737
$resolver->setAllowedTypes('jobs', array('int', 'null'));
@@ -57,18 +57,13 @@ public function run(ContextInterface $context)
5757
$config = $this->getConfiguration();
5858
$files = $context->getFiles()->extensions($config['triggered_by']);
5959

60-
$args = $this->processBuilder->createArgumentsForCommand('parallel-lint');
61-
$args->add('--no-colors');
62-
if (!empty($config['jobs'])) {
63-
$args->add('-j');
64-
$args->add($config['jobs']);
65-
}
66-
$args->addArgumentArrayWithSeparatedValue('--exclude', $config['exclude']);
67-
$args->add('-e');
68-
$args->addOptionalCommaSeparatedArgument('%s', $config['triggered_by']);
69-
$args->addFiles($files);
60+
$arguments = $this->processBuilder->createArgumentsForCommand('parallel-lint');
61+
$arguments->add('--no-colors');
62+
$arguments->addOptionalArgumentWithSeparatedValue('-j', $config['jobs']);
63+
$arguments->addArgumentArrayWithSeparatedValue('--exclude', $config['exclude']);
64+
$arguments->addFiles($files);
7065

71-
$process = $this->processBuilder->buildProcess($args);
66+
$process = $this->processBuilder->buildProcess($arguments);
7267
$process->run();
7368

7469
if (!$process->isSuccessful()) {

0 commit comments

Comments
 (0)