Merge pull request #62 from gabriel403/feature/php-cs-fixer
PHP CS Fixer and indentation fix
This commit is contained in:
commit
2345dde058
89
PHPCI/Plugin/PhpCsFixer.php
Normal file
89
PHPCI/Plugin/PhpCsFixer.php
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPCI - Continuous Integration for PHP
|
||||
*
|
||||
* @copyright Copyright 2013, Block 8 Limited.
|
||||
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
||||
* @link http://www.phptesting.org/
|
||||
*/
|
||||
|
||||
namespace PHPCI\Plugin;
|
||||
|
||||
/**
|
||||
* PHP CS Fixer - Works with the PHP CS Fixer for testing coding standards.
|
||||
* @author Gabriel Baker <gabriel@autonomicpilot.co.uk>
|
||||
* @package PHPCI
|
||||
* @subpackage Plugins
|
||||
*/
|
||||
class PhpCsFixer implements \PHPCI\Plugin
|
||||
{
|
||||
protected $phpci;
|
||||
|
||||
protected $args = '';
|
||||
|
||||
protected $workingDir = '';
|
||||
protected $level = 'all';
|
||||
protected $dryRun = true;
|
||||
protected $verbose = false;
|
||||
protected $diff = false;
|
||||
protected $levels = array('psr0', 'psr1', 'psr2', 'all');
|
||||
|
||||
public function __construct(\PHPCI\Builder $phpci, array $options = array())
|
||||
{
|
||||
$this->phpci = $phpci;
|
||||
$this->workingdir = $this->phpci->buildPath;
|
||||
$this->buildArgs($options);
|
||||
}
|
||||
|
||||
public function execute()
|
||||
{
|
||||
$success = false;
|
||||
|
||||
$curdir = getcwd();
|
||||
chdir($this->workingdir);
|
||||
|
||||
$cmd = PHPCI_BIN_DIR . 'php-cs-fixer fix . %s';
|
||||
$success = $this->phpci->executeCommand($cmd, $this->args);
|
||||
|
||||
chdir($curdir);
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
public function buildArgs($options)
|
||||
{
|
||||
$argstring = "";
|
||||
|
||||
if ( array_key_exists('verbose', $options) && $options['verbose'] )
|
||||
{
|
||||
$this->verbose = true;
|
||||
$this->args .= ' --verbose';
|
||||
}
|
||||
|
||||
if ( array_key_exists('diff', $options) && $options['diff'] )
|
||||
{
|
||||
$this->diff = true;
|
||||
$this->args .= ' --diff';
|
||||
}
|
||||
|
||||
if ( array_key_exists('level', $options) && array_key_exists($options['level'], $this->levels) )
|
||||
{
|
||||
$this->level = $options['level'];
|
||||
$this->args .= ' --level='.$options['level'];
|
||||
}
|
||||
|
||||
if ( array_key_exists('dryrun', $options) && $options['dryrun'] )
|
||||
{
|
||||
$this->dryRun = true;
|
||||
$this->args .= ' --dry-run';
|
||||
}
|
||||
|
||||
if ( array_key_exists('workingdir', $options)
|
||||
&& $options['workingdir']
|
||||
&& is_dir($this->phpci->buildPath.$options['workingdir']) )
|
||||
{
|
||||
$this->workingdir = $this->phpci->buildPath.$options['workingdir'];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,36 +1,37 @@
|
|||
{
|
||||
"name": "block8/phpci",
|
||||
"description": "Simple continuous integration for PHP projects.",
|
||||
"name" : "block8/phpci",
|
||||
"description" : "Simple continuous integration for PHP projects.",
|
||||
"minimum-stability": "dev",
|
||||
"type": "library",
|
||||
"keywords": ["php", "phpci", "ci", "continuous", "integration", "testing", "phpunit", "continuous integration", "jenkins", "travis"],
|
||||
"homepage": "http://www.phptesting.org/",
|
||||
"license": "BSD-2-Clause",
|
||||
"type" : "library",
|
||||
"keywords" : ["php", "phpci", "ci", "continuous", "integration", "testing", "phpunit", "continuous integration", "jenkins", "travis"],
|
||||
"homepage" : "http://www.phptesting.org/",
|
||||
"license" : "BSD-2-Clause",
|
||||
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dan Cryer",
|
||||
"email": "dan.cryer@block8.co.uk",
|
||||
"name" : "Dan Cryer",
|
||||
"email" : "dan.cryer@block8.co.uk",
|
||||
"homepage": "http://www.block8.co.uk",
|
||||
"role": "Developer"
|
||||
"role" : "Developer"
|
||||
}
|
||||
],
|
||||
|
||||
"support": {
|
||||
"email": "hello+phpci@block8.co.uk",
|
||||
"email" : "hello+phpci@block8.co.uk",
|
||||
"issues": "https://github.com/Block8/PHPCI/issues",
|
||||
"source": "https://github.com/Block8/PHPCI"
|
||||
},
|
||||
|
||||
"require": {
|
||||
"block8/b8framework": "dev-master",
|
||||
"phpunit/phpunit": "3.*",
|
||||
"phpmd/phpmd" : "1.*",
|
||||
"sebastian/phpcpd": "1.*",
|
||||
"block8/b8framework" : "dev-master",
|
||||
"phpunit/phpunit" : "3.*",
|
||||
"phpmd/phpmd" : "1.*",
|
||||
"sebastian/phpcpd" : "1.*",
|
||||
"squizlabs/php_codesniffer": "1.*",
|
||||
"ircmaxell/password-compat": "1.x",
|
||||
"phpspec/phpspec": "2.*",
|
||||
"symfony/yaml": "2.2.x-dev",
|
||||
"symfony/console": "2.2.*"
|
||||
"phpspec/phpspec" : "2.*",
|
||||
"symfony/yaml" : "2.2.x-dev",
|
||||
"symfony/console" : "2.2.*",
|
||||
"fabpot/php-cs-fixer" : "0.3.*@dev"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue