-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHPCS Configuration management #1
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No critical issues found. Some minor suggestions for improvement.
/** | ||
* @var Composer | ||
*/ | ||
protected $composer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you do not plan on having the Plugin
class extended, these properties might as well be private
.
* @throws LogicException | ||
* @throws ProcessFailedException | ||
*/ | ||
public function onScriptPost() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name onScriptPost
seems unclear to me. I would prefer a fooEventHandler
or fooHandler
style name.
{ | ||
// Ensure PHP_CodeSniffer is installed | ||
if ($this->isPHPCodeSnifferInstalled() === false) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
False language construct. It would be better to invert the check (!== false
or === true
) and move the statement below in to the if
body. It might even be possible to collapse both if
's into one.
*/ | ||
private function loadInstalledPaths() | ||
{ | ||
$phpcs = new Process($this->phpCodeSnifferBin . ' --config-show installed_paths'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating a new Process
three times you might want to look into using the ProcessBuilder factory.
$this->builder = new ProcessBuilder();
$this->builder->setPrefix($this->phpCodeSnifferBin);
...
$this->builder
->setArguments(array('--list', '--file=archive.tar.gz'))
->getProcess()
->mustRun() /* or ->run()*/
…nged naming and visibility of some methods & variables.
|
||
// This changes in case we do have installed_paths | ||
if (count($this->installedPaths) !== 0) { | ||
$arguments = ['--config-set', 'installed_paths', implode(',', $this->installedPaths)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason for not using array_push ($argument, implode(',', $this->installedPaths));
instead of defining the entire array again?
Oh, wait. Nevermind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the middle element is the same...
Initial commit of a version which works by changing PHP_CodeSniffer's configuration