src/Parse/UnifiedDiffParser.php
private function parseHunk(array $hunkTokenList): Hunk
    {
        [$originalStart, $originalCount, $newStart, $newCount, $tokensReadCount] = $this->getHunkMeta($hunkTokenList);
        $originalLineNo = $originalStart;
        $newLineNo = $newStart;
        $lineList = [];

        $tokenCount = count($hunkTokenList);
        for ($i = $tokensReadCount; $i < $tokenCount; $i++) {
            $operation = $this->mapLineOperation($hunkTokenList[$i]);

            $lineList[] = new Line(
                (Line::ADDED) === $operation ? Line::LINE_NOT_PRESENT : $originalLineNo,
                (Line::REMOVED) === $operation ? Line::LINE_NOT_PRESENT : $newLineNo,
                $operation,
                $hunkTokenList[$i]->getValue()
            );

            if (Line::ADDED === $operation) {
                $newLineNo++;
            } elseif (Line::REMOVED === $operation) {
                $originalLineNo++;
            } else {
                $originalLineNo++;
                $newLineNo++;
            }
        }

        return new Hunk(
            $originalStart,
            $originalCount,
            $newStart,
            $newCount,
            $lineList
        );
    }
private function parseHunk(array $hunkTokenList): Hunk
    {
        [$originalStart, $originalCount, $newStart, $newCount, $tokensReadCount] = $this->getHunkMeta($hunkTokenList);
        $originalLineNo = $originalStart;
        $newLineNo = $newStart;
        $lineList = [];

        $tokenCount = count($hunkTokenList);
        for ($i = $tokensReadCount; $i < $tokenCount; $i++) {
            $operation = $this->mapLineOperation($hunkTokenList[$i]);

            $lineList[] = new Line(
                (Line::ADDED) === $operation ? Line::LINE_NOT_PRESENT : $originalLineNo,
                (Line::REMOVED) === $operation ? Line::LINE_NOT_PRESENT : $newLineNo,
                $operation,
                $hunkTokenList[$i]->getValue()
            );

            if (Line::ADDED === $operation) {
                $newLineNo++;
            } elseif (Line::REMOVED === $operation) {
                $originalLineNo++;
            } else {
                $originalLineNo++;
                $newLineNo++;
            }
        }

        return new Hunk(
            $originalStart,
            $originalCount,
            $newStart,
            $newCount,
            $lineList
        );
    }
private function parseHunk ( array $ hunkTokenList ) : Hunk { [ $ originalStart , $ originalCount , $ newStart , $ newCount , $ tokensReadCount ] = $ this -> getHunkMeta ( $ hunkTokenList ) ; $ originalLineNo = $ originalStart ; $ newLineNo = $ newStart ; $ lineList = [ ] ; $ tokenCount = count ( $ hunkTokenList ) ; for ( $ i = $ tokensReadCount ; $ i < $ tokenCount ; $ i ++ ) { $ operation = $ this -> mapLineOperation ( $ hunkTokenList [ $ i ] ) ; $ lineList [ ] = new Line ( ( Line :: ADDED ) === $ operation ? Line :: LINE_NOT_PRESENT : $ originalLineNo , ( Line :: REMOVED ) === $ operation ? Line :: LINE_NOT_PRESENT : $ newLineNo , $ operation , $ hunkTokenList [ $ i ] -> getValue ( ) ) ; if ( Line :: ADDED === $ operation ) { $ newLineNo ++ ; } elseif ( Line :: REMOVED === $ operation ) { $ originalLineNo ++ ; } else { $ originalLineNo ++ ; $ newLineNo ++ ; } } return new Hunk ( $ originalStart , $ originalCount , $ newStart , $ newCount , $ lineList ) ; }
Parse out the contents of a hunk.

@param Token[] $hunkTokenList

@return Hunk
Parse out the contents of a hunk .