2013-09-20 12:57:23 +02:00
|
|
|
<?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;
|
|
|
|
|
2013-10-10 02:01:06 +02:00
|
|
|
use PHPCI\Builder;
|
|
|
|
use PHPCI\Model\Build;
|
|
|
|
|
2013-09-20 12:57:23 +02:00
|
|
|
/**
|
|
|
|
* Php Parallel Lint Plugin - Provides access to PHP lint functionality.
|
|
|
|
* @author Vaclav Makes <vaclav@makes.cz>
|
|
|
|
* @package PHPCI
|
|
|
|
* @subpackage Plugins
|
|
|
|
*/
|
|
|
|
class PhpParallelLint implements \PHPCI\Plugin
|
|
|
|
{
|
2013-11-13 19:18:24 +01:00
|
|
|
/**
|
|
|
|
* @var \PHPCI\Builder
|
|
|
|
*/
|
2013-09-20 12:57:23 +02:00
|
|
|
protected $phpci;
|
|
|
|
|
2013-11-13 19:18:24 +01:00
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $directory;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array - paths to ignore
|
|
|
|
*/
|
|
|
|
protected $ignore;
|
|
|
|
|
2013-10-10 02:01:06 +02:00
|
|
|
public function __construct(Builder $phpci, Build $build, array $options = array())
|
2013-09-20 12:57:23 +02:00
|
|
|
{
|
|
|
|
$path = $phpci->buildPath;
|
|
|
|
$this->phpci = $phpci;
|
|
|
|
$this->directory = isset($options['directory']) ? $path . $options['directory'] : $path;
|
2013-11-13 19:18:24 +01:00
|
|
|
$this->ignore = $this->phpci->ignore;
|
|
|
|
|
|
|
|
if (isset($options['ignore'])) {
|
|
|
|
$this->ignore = $options['ignore'];
|
|
|
|
}
|
2013-09-20 12:57:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes parallel lint
|
|
|
|
*/
|
|
|
|
public function execute()
|
|
|
|
{
|
2013-11-13 19:18:24 +01:00
|
|
|
list($ignore) = $this->getFlags();
|
|
|
|
|
|
|
|
$phplint = $this->phpci->findBinary('parallel-lint');
|
|
|
|
|
|
|
|
if (!$phplint) {
|
|
|
|
$this->phpci->logFailure('Could not find parallel-lint.');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
$cmd = $phplint . ' %s "%s"';
|
|
|
|
$success = $this->phpci->executeCommand(
|
|
|
|
$cmd,
|
|
|
|
$ignore,
|
|
|
|
$this->directory
|
|
|
|
);
|
|
|
|
|
|
|
|
return $success;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getFlags()
|
|
|
|
{
|
|
|
|
$ignore = '';
|
|
|
|
if (count($this->ignore)) {
|
|
|
|
$ignore = ' --exclude ' . implode(' --exclude ', $this->ignore);
|
|
|
|
}
|
2013-09-20 12:57:23 +02:00
|
|
|
|
2013-11-13 19:18:24 +01:00
|
|
|
return array($ignore);
|
2013-09-20 12:57:23 +02:00
|
|
|
}
|
|
|
|
}
|