/** * @param $source string * * @return string|null */ protected function lintSource($source) { if (!isset(static::$linter)) { return; } if ($this->isLintException($source)) { return; } try { static::$linter->lintSource($source); } catch (\Exception $e) { return $e->getMessage() . "\n\nSource:\n{$source}"; } }
/** * @covers PhpCsFixer\Linter\Linter::lintSource * * @expectedException PhpCsFixer\Linter\LintingException * @expectedExceptionMessageRegExp /syntax error, unexpected (?:'echo' \(T_ECHO\))|(?:T_ECHO)/ */ public function testLintSourceWithBadCode() { $linter = new Linter(); $linter->lintSource('<?php echo echo;'); }