Skip to content

Commit

Permalink
Merge pull request #529 from phurni/feature/phpcs-more-options
Browse files Browse the repository at this point in the history
Add more options for the 'phpcs' task, in particular the 'report' one.
  • Loading branch information
veewee authored Aug 31, 2018
2 parents f234b88 + abb8903 commit 50a0d9e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
15 changes: 15 additions & 0 deletions doc/tasks/phpcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ parameters:
error_severity: ~
warning_severity: ~
tab_width: ~
report: full
report_width: ~
whitelist_patterns: []
encoding: ~
ignore_patterns: []
Expand Down Expand Up @@ -76,6 +78,19 @@ By default, the standard will specify the optimal tab-width of the code. If you

The default encoding used by PHP_CodeSniffer (is ISO-8859-1).

**report**

*Default: full*

The report type output by PHP_CodeSniffer, put `code` to see a code snippet of the offending code.
Consult the [complete list](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#setting-the-default-report-format) for more formats.

**report_width**

*Default: null*

PHP_CodeSniffer will print all screen-based reports 80 characters wide. You may override this size so that long lines do not wrap.

**whitelist_patterns**

*Default: []*
Expand Down
9 changes: 7 additions & 2 deletions src/Task/Phpcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function getConfigurableOptions()
'severity' => null,
'error_severity' => null,
'warning_severity' => null,
'triggered_by' => ['php']
'triggered_by' => ['php'],
'report' => 'full',
'report_width' => null,
]);

$resolver->addAllowedTypes('standard', ['null', 'string']);
Expand All @@ -54,6 +56,8 @@ public function getConfigurableOptions()
$resolver->addAllowedTypes('error_severity', ['null', 'int']);
$resolver->addAllowedTypes('warning_severity', ['null', 'int']);
$resolver->addAllowedTypes('triggered_by', ['array']);
$resolver->addAllowedTypes('report', ['null', 'string']);
$resolver->addAllowedTypes('report_width', ['null', 'int']);

return $resolver;
}
Expand Down Expand Up @@ -91,7 +95,6 @@ public function run(ContextInterface $context)

$arguments = $this->processBuilder->createArgumentsForCommand('phpcs');
$arguments = $this->addArgumentsFromConfig($arguments, $config);
$arguments->add('--report-full');
$arguments->add('--report-json');
$arguments->addFiles($files);

Expand Down Expand Up @@ -125,6 +128,8 @@ protected function addArgumentsFromConfig(ProcessArgumentsCollection $arguments,
$arguments->addOptionalArgument('--standard=%s', $config['standard']);
$arguments->addOptionalArgument('--tab-width=%s', $config['tab_width']);
$arguments->addOptionalArgument('--encoding=%s', $config['encoding']);
$arguments->addOptionalArgument('--report=%s', $config['report']);
$arguments->addOptionalIntegerArgument('--report-width=%s', $config['report_width']);
$arguments->addOptionalIntegerArgument('--severity=%s', $config['severity']);
$arguments->addOptionalIntegerArgument('--error-severity=%s', $config['error_severity']);
$arguments->addOptionalIntegerArgument('--warning-severity=%s', $config['warning_severity']);
Expand Down

0 comments on commit 50a0d9e

Please sign in to comment.