<commit_before><?php

/*
 * This file is part of the CS library.
 *
 * Copyright (c) 2015 LIN3S <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace LIN3S\CS\Checker;

use LIN3S\CS\Exception\CheckFailException;
use Symfony\Component\Process\ProcessBuilder;

/**
 * Checker that automatizes all the logic about Fabien Potencier's PHP CS Fixer.
 *
 * @author <NAME> <<EMAIL>>
 */
final class PhpCsFixer extends Checker
{
    /**
     * {@inheritdoc}
     */
    public static function check(array $files = [], array $parameters = null)
    {
        $processBuilder = new ProcessBuilder([
            'php',
            'vendor/fabpot/php-cs-fixer/php-cs-fixer',
            'fix',
            $parameters['phpcsfixer_path'],
            '--level=' . $parameters['phpcsfixer_level'],
            '--fixers=' . implode(',', $parameters['phpcsfixer_fixers'])
        ]);
        $processBuilder->setWorkingDirectory($parameters['root_directory']);
        $process = $processBuilder->getProcess();
        $process->run();

        if (!$process->isSuccessful()) {
            throw new CheckFailException('PHP CS Fixer', 'Something fails during php cs fixer\'s process');
        }<commit_msg>Fixed PhpCsFixer Symfony Process collision<commit_after><?php

/*
 * This file is part of the CS library.
 *
 * Copyright (c) 2015 LIN3S <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace LIN3S\CS\Checker;

/**
 * Checker that automatizes all the logic about Fabien Potencier's PHP CS Fixer.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
final class PhpCsFixer extends Checker
{
    /**
     * {@inheritdoc}
     */
    public static function check(array $files = [], array $parameters = null)
    {
        // Exec PHP function is used because php-cs-fixer uses Symfony Process component inside
        // ProcessBuilder fails when is launched from another ProcessBuilder
        $commandLine = [
            'php',
            'vendor/fabpot/php-cs-fixer/php-cs-fixer',
            'fix',
            $parameters['phpcsfixer_path'],
            '--level=' . $parameters['phpcsfixer_level'],
            '--fixers=' . implode(',', $parameters['phpcsfixer_fixers'])
        ];
        exec(implode(' ', $commandLine));
{'fraction_non_alphanumeric': 0.13081036610448374, 'fraction_numerical': 0.0053475935828877, 'mean_word_length': 2.7415384615384615, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6244199', 'n_tokens_mistral': 718, 'n_tokens_neox': 706, 'n_words': 201}