Skip to content
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

Merged
merged 2 commits into from
Nov 1, 2016
Merged

Conversation

frenck
Copy link
Contributor

@frenck frenck commented Oct 31, 2016

Initial commit of a version which works by changing PHP_CodeSniffer's configuration

Copy link
Member

@Potherca Potherca left a 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;
Copy link
Member

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()
Copy link
Member

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;
Copy link
Member

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');
Copy link
Member

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)];
Copy link
Member

@Potherca Potherca Nov 1, 2016

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.

Copy link
Contributor Author

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...

@frenck frenck merged commit 771d652 into master Nov 1, 2016
@frenck frenck deleted the phpcs-config-set-version branch November 1, 2016 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants