Skip to content

Commit

Permalink
Add Moodle PHPDoc checker.
Browse files Browse the repository at this point in the history
  • Loading branch information
kabalin committed Nov 22, 2018
1 parent 17648bb commit 7cc6985
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bin/moodle-plugin-ci
Expand Up @@ -24,6 +24,7 @@ use MoodlePluginCI\Command\InstallCommand;
use MoodlePluginCI\Command\MessDetectorCommand;
use MoodlePluginCI\Command\MustacheCommand;
use MoodlePluginCI\Command\ParallelCommand;
use MoodlePluginCI\Command\PHPDocCommand;
use MoodlePluginCI\Command\PHPLintCommand;
use MoodlePluginCI\Command\PHPUnitCommand;
use MoodlePluginCI\Command\SavePointsCommand;
Expand Down Expand Up @@ -69,6 +70,7 @@ $application->add(new InstallCommand(ENV_FILE));
$application->add(new MessDetectorCommand());
$application->add(new MustacheCommand());
$application->add(new ParallelCommand());
$application->add(new PHPDocCommand());
$application->add(new PHPLintCommand());
$application->add(new PHPUnitCommand());
$application->add(new SavePointsCommand());
Expand Down
58 changes: 58 additions & 0 deletions src/Command/PHPDocCommand.php
@@ -0,0 +1,58 @@
<?php

/*
* This file is part of the Moodle Plugin CI package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Copyright (c) 2018 Blackboard Inc. (http://www.blackboard.com)
* License http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace MoodlePluginCI\Command;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\ProcessBuilder;

class PHPDocCommand extends AbstractPluginCommand
{
use ExecuteTrait;

protected function configure()
{
parent::configure();

$this->setName('phpdoc')
->setDescription('Run Moodle PHPDoc Checker on a plugin');
}

protected function initialize(InputInterface $input, OutputInterface $output)
{
parent::initialize($input, $output);
$this->initializeExecute($output, $this->getHelper('process'));
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$this->outputHeading($output, 'Moodle PHPDoc Checker on %s');

$process = $this->execute->passThroughProcess(
ProcessBuilder::create()
->setPrefix('php')
->add('local/moodlecheck/cli/moodlecheck.php')
->add('-p=' . $this->plugin->directory)
->add('-f=text')
->setTimeout(null)
->setWorkingDirectory($this->moodle->directory)
->getProcess()
);

// moodlecheck.php does not return valid exit status,
// We have to parse output to see if there are errors.
$results = $process->getOutput();
return (preg_match('/\s+Line/', $results)) ? 1 : 0;
}
}

0 comments on commit 7cc6985

Please sign in to comment.