private function Parser::parseFileDiff in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/sebastian/diff/src/Parser.php \SebastianBergmann\Diff\Parser::parseFileDiff()
Parameters
Diff $diff:
array $lines:
1 call to Parser::parseFileDiff()
- Parser::parse in vendor/
sebastian/ diff/ src/ Parser.php
File
- vendor/
sebastian/ diff/ src/ Parser.php, line 68
Class
- Parser
- Unified diff parser.
Namespace
SebastianBergmann\DiffCode
private function parseFileDiff(Diff $diff, array $lines) {
$chunks = array();
foreach ($lines as $line) {
if (preg_match('/^@@\\s+-(?P<start>\\d+)(?:,\\s*(?P<startrange>\\d+))?\\s+\\+(?P<end>\\d+)(?:,\\s*(?P<endrange>\\d+))?\\s+@@/', $line, $match)) {
$chunk = new Chunk($match['start'], isset($match['startrange']) ? max(1, $match['startrange']) : 1, $match['end'], isset($match['endrange']) ? max(1, $match['endrange']) : 1);
$chunks[] = $chunk;
$diffLines = array();
continue;
}
if (preg_match('/^(?P<type>[+ -])?(?P<line>.*)/', $line, $match)) {
$type = Line::UNCHANGED;
if ($match['type'] == '+') {
$type = Line::ADDED;
}
elseif ($match['type'] == '-') {
$type = Line::REMOVED;
}
$diffLines[] = new Line($type, $match['line']);
if (isset($chunk)) {
$chunk
->setLines($diffLines);
}
}
}
$diff
->setChunks($chunks);
}