src/Parse/UnifiedDiffTokenizer.php
private function getHunkTokens(
        array $diffLineList,
        int &$currentLine
    ): array {
        $tokenList = [];
        $hunkTokens = $this->getHunkStartTokens($diffLineList[$currentLine]);

        // We have found a hunk start, process hunk lines
        if ($this->isHunkStart($hunkTokens)) {
            $currentLine++;

            [$originalLineCount, $newLineCount] = $this->getHunkLineCounts($hunkTokens);
            $addedCount = 0;
            $removedCount = 0;
            $unchangedCount = 0;

            // Iterate until we have the correct number of original & new lines
            $lineCount = count($diffLineList);
            for ($i = $currentLine; $i < $lineCount; $i++) {
                $tokenList[] = $this->getHunkLineToken(
                    $addedCount,
                    $removedCount,
                    $unchangedCount,
                    $diffLineList[$i]
                );

                // We have reached the line count for original & new versions of hunk
                if (
                    $removedCount + $unchangedCount === $originalLineCount
                    && $addedCount + $unchangedCount === $newLineCount
                ) {
                    break;
                }
            }
        }

        return array_merge($hunkTokens, $tokenList);
    }
private function getHunkTokens(
        array $diffLineList,
        int &$currentLine
    ): array {
        $tokenList = [];
        $hunkTokens = $this->getHunkStartTokens($diffLineList[$currentLine]);

        // We have found a hunk start, process hunk lines
        if ($this->isHunkStart($hunkTokens)) {
            $currentLine++;

            [$originalLineCount, $newLineCount] = $this->getHunkLineCounts($hunkTokens);
            $addedCount = 0;
            $removedCount = 0;
            $unchangedCount = 0;

            // Iterate until we have the correct number of original & new lines
            $lineCount = count($diffLineList);
            for ($i = $currentLine; $i < $lineCount; $i++) {
                $tokenList[] = $this->getHunkLineToken(
                    $addedCount,
                    $removedCount,
                    $unchangedCount,
                    $diffLineList[$i]
                );

                // We have reached the line count for original & new versions of hunk
                if (
                    $removedCount + $unchangedCount === $originalLineCount
                    && $addedCount + $unchangedCount === $newLineCount
                ) {
                    break;
                }
            }
        }

        return array_merge($hunkTokens, $tokenList);
    }
private function getHunkTokens ( array $ diffLineList , int & $ currentLine ) : array { $ tokenList = [ ] ; $ hunkTokens = $ this -> getHunkStartTokens ( $ diffLineList [ $ currentLine ] ) ; // We have found a hunk start, process hunk lines if ( $ this -> isHunkStart ( $ hunkTokens ) ) { $ currentLine ++ ; [ $ originalLineCount , $ newLineCount ] = $ this -> getHunkLineCounts ( $ hunkTokens ) ; $ addedCount = 0 ; $ removedCount = 0 ; $ unchangedCount = 0 ; // Iterate until we have the correct number of original & new lines $ lineCount = count ( $ diffLineList ) ; for ( $ i = $ currentLine ; $ i < $ lineCount ; $ i ++ ) { $ tokenList [ ] = $ this -> getHunkLineToken ( $ addedCount , $ removedCount , $ unchangedCount , $ diffLineList [ $ i ] ) ; // We have reached the line count for original & new versions of hunk if ( $ removedCount + $ unchangedCount === $ originalLineCount && $ addedCount + $ unchangedCount === $ newLineCount ) { break ; } } } return array_merge ( $ hunkTokens , $ tokenList ) ; }
Process a hunk.

@param string[] $diffLineList
@param int $currentLine

@return Token[]
Process a hunk .