public function review(ReporterInterface $reporter, ReviewableInterface $file)
    {
        $bin = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, 'vendor/bin/phpcs');
        $cmd = $bin . ' --report=json ';

        if ($this->getOptionsForConsole()) {
            $cmd .= $this->getOptionsForConsole();
        }

        $cmd .= $file->getFullPath();

        $process = $this->getProcess($cmd);
        $process->run();

        if (! $process->isSuccessful()) {
            // Create the array of outputs and remove empty values.
            $output = json_decode($process->getOutput(), true);

            $filter = function ($acc, $file) {
                if ($file['errors'] > 0 || $file['warnings'] > 0) {
                    return $acc + $file['messages'];
                }
            };

            foreach (array_reduce($output['files'], $filter, []) as $error) {
                $message = $error['message'] . ' on line ' . $error['line'];
                $reporter->warning($message, $this, $file);
            }
        }
    }
public function review(ReporterInterface $reporter, ReviewableInterface $file)
    {
        $bin = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, 'vendor/bin/phpcs');
        $cmd = $bin . ' --report=json ';

        if ($this->getOptionsForConsole()) {
            $cmd .= $this->getOptionsForConsole();
        }

        $cmd .= $file->getFullPath();

        $process = $this->getProcess($cmd);
        $process->run();

        if (! $process->isSuccessful()) {
            // Create the array of outputs and remove empty values.
            $output = json_decode($process->getOutput(), true);

            $filter = function ($acc, $file) {
                if ($file['errors'] > 0 || $file['warnings'] > 0) {
                    return $acc + $file['messages'];
                }
            };

            foreach (array_reduce($output['files'], $filter, []) as $error) {
                $message = $error['message'] . ' on line ' . $error['line'];
                $reporter->warning($message, $this, $file);
            }
        }
    }
public function review ( ReporterInterface $ reporter , ReviewableInterface $ file ) { $ bin = str_replace ( [ '/' , '\\' ] , DIRECTORY_SEPARATOR , 'vendor/bin/phpcs' ) ; $ cmd = $ bin . ' --report=json ' ; if ( $ this -> getOptionsForConsole ( ) ) { $ cmd .= $ this -> getOptionsForConsole ( ) ; } $ cmd .= $ file -> getFullPath ( ) ; $ process = $ this -> getProcess ( $ cmd ) ; $ process -> run ( ) ; if ( ! $ process -> isSuccessful ( ) ) { // Create the array of outputs and remove empty values. $ output = json_decode ( $ process -> getOutput ( ) , true ) ; $ filter = function ( $ acc , $ file ) { if ( $ file [ 'errors' ] > 0 || $ file [ 'warnings' ] > 0 ) { return $ acc + $ file [ 'messages' ] ; } } ; foreach ( array_reduce ( $ output [ 'files' ] , $ filter , [ ] ) as $ error ) { $ message = $ error [ 'message' ] . ' on line ' . $ error [ 'line' ] ; $ reporter -> warning ( $ message , $ this , $ file ) ; } } }
Checks PHP files using PHP_CodeSniffer.
Checks PHP files using PHP_CodeSniffer .