for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Funivan\Cs\Tools\Composer;
use Funivan\Cs\FileTool\FileTool;
use Funivan\Cs\Fs\File;
use Funivan\Cs\Fs\FileFilter;
use Funivan\Cs\Report\Report;
use Symfony\Component\Process\Process;
/**
* @author Ivan Shcherbak <[email protected]> 2016
*/
class ComposerReview implements FileTool {
const NAME = 'composer_review';
* @inheritdoc
public function getName() {
return self::NAME;
}
public function getDescription() {
return 'Validate composer.json file';
public function canProcess(File $file) {
return (new FileFilter())->name(['!^composer.json$!'])->isValid($file);
public function process(File $file, Report $report) {
$process = new Process(sprintf('composer validate %s', $file->getPath()));
$process->run();
if ($process->isSuccessful()) {
return;
$errorOutput = $process->getErrorOutput();
preg_match('!Parse error on line (\d+):!', $errorOutput, $matchedLine);
$line = 1;
if (isset($matchedLine[1])) {
$line = (int) $matchedLine[1];
$report->addMessage($file, $this, 'Invalid composer.json file format', $line);