* improved dev fixtures with more diversity, more data, better testcases, user avatars #42 * added customer stats to dashboard, fixed column length for 3 widgets #42 * fixed empty alias - display empty message for new user #42 * unified-ui for "new" toolbar icon #42 * use kimai2_ as database prefix #42 * added customer stats to dashboard, fixed column length for 3 widgets #42 * fix long project/customer names in "currently active" navbar flyout" #42 * added services config for dev environment #42 * added command to run unit tests #42 * added command to run integration tests #42 * added command to run code sniffer #42 * added phpcs and phpunit to composer #42 * created tests directory #42 * fixed code sniffer warnings #42 * added function to switch result type from Pagerfanta to QueryBuilder #42 * dramatically reduced database calls by using custom joined query #42 * added command to install kimai dependencies #42 * added dev:reset command #42
85 lines
2.0 KiB
PHP
85 lines
2.0 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Kimai package.
|
|
*
|
|
* (c) Kevin Papst <kevin@kevinpapst.de>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace AppBundle\Command;
|
|
|
|
use Symfony\Component\Console\Command\Command;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
|
|
|
/**
|
|
* Command used to check the project coding styles.
|
|
*
|
|
* @author Kevin Papst <kevin@kevinpapst.de>
|
|
*/
|
|
class RunCodeSnifferCommand extends Command
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
protected $rootDir;
|
|
|
|
/**
|
|
* RunCodeSnifferCommand constructor.
|
|
* @param $rootDir
|
|
*/
|
|
public function __construct($rootDir)
|
|
{
|
|
$this->rootDir = realpath($rootDir . '/../');
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setName('kimai:dev:phpcs')
|
|
->setDescription('Run PHP_CodeSniffer to check for the projects coding style')
|
|
;
|
|
}
|
|
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
$io = new SymfonyStyle($input, $output);
|
|
|
|
$this->executeCodeSniffer($io, '/src');
|
|
$this->executeCodeSniffer($io, '/tests');
|
|
$this->executeCodeSniffer($io, '/app/Resources/views');
|
|
}
|
|
|
|
/**
|
|
* @param string $directory
|
|
*/
|
|
protected function executeCodeSniffer(SymfonyStyle $io, $directory)
|
|
{
|
|
$directory = $this->rootDir . $directory;
|
|
|
|
$exitCode = 0;
|
|
ob_start();
|
|
passthru($this->rootDir . '/bin/phpcs --standard=PSR2 ' . $directory, $exitCode);
|
|
$result = ob_get_clean();
|
|
|
|
$io->write($result);
|
|
|
|
if ($exitCode > 0) {
|
|
$io->error('Found problems while checking sources at: ' . $directory);
|
|
} else {
|
|
$io->success('All sources look good at: ' . $directory);
|
|
}
|
|
}
|
|
}
|