コード例 #1
0
 /**
  * @covers \spriebsch\PHPca\Rule\MaximumLineLengthRule
  */
 public function testTabsCountAsFourCharactersTowardsLengthPass()
 {
     $this->init(__DIR__ . '/../_testdata/MaximumLineLengthRule/tabbed_over_pass.php');
     $rule = new MaximumLineLengthRule();
     $conf = new Configuration("");
     $conf->setLineEndings("\n");
     $rule->setConfiguration($conf);
     $rule->configure(array("line_length" => 100));
     $rule->check($this->file, $this->result);
     $this->assertFalse($this->result->hasViolations());
 }
コード例 #2
0
ファイル: Syntax.php プロジェクト: raisinbread/li3_qa
 /**
  * Main method.
  *
  * @param string $path Absolute path to file or directory.
  * @return boolean
  */
 public function run()
 {
     $path = $this->request->action;
     if (!($path = realpath($path))) {
         $this->error('Not a valid path.');
         return false;
     }
     if (!($this->_project = $this->_project($path))) {
         $this->error('Not a valid project.');
         return false;
     }
     if (is_dir($this->_project . '/.git')) {
         $this->_vcs = 'git';
     }
     $app = new Application(getcwd());
     $app->registerProgressPrinter($this);
     $file = Libraries::get('phpca', 'path') . '/Standard/lithium.ini';
     $config = new Configuration(getcwd());
     $config->setStandard(parse_ini_file($file, true));
     $config->setConfiguration(array());
     if (!isset($this->php)) {
         $this->php = PHP_BINDIR . '/' . (substr(PHP_OS, 0, 3) == 'WIN' ? 'php.exe' : 'php');
     }
     if (!file_exists($this->php)) {
         $message = 'You must specify a valid absolute path to a PHP executable. ';
         $message .= 'Try using `li3 syntax --php=PATH ...`.';
         $this->error($message);
         return false;
     }
     if (!$this->plain) {
         $this->header('Syntax');
         $this->out(null, 1);
     }
     $begin = microtime(true);
     try {
         $result = $app->run($this->php, $path, $config);
     } catch (Exception $e) {
         $this->out($message = $e->getMessage());
         return $message == 'No PHP files to analyze';
     }
     if ($this->metrics) {
         $this->_metrics($result, microtime(true) - $begin);
     }
     return !$result->hasErrors();
 }
コード例 #3
0
 /**
  * @covers \spriebsch\PHPca\Rule\NoCarriageReturnsRule
  */
 public function testCarriageReturns()
 {
     $this->init(__DIR__ . '/../_testdata/NoCarriageReturnsRule/carriagereturns.php');
     $configuration = new Configuration(__DIR__);
     $configuration->setLineEndings("\n");
     $rule = new NoCarriageReturnsRule();
     $rule->setConfiguration($configuration);
     $rule->check($this->file, $this->result);
     $this->assertEquals(26, $this->result->getNumberOfViolations());
 }