src/Parse/UnifiedDiffTokenizer.php
private function getFilenameTokens(array $diffLineList, int $currentLine): array
    {
        $filenameTokens = [];

        // Get hunk metadata
        $hunkTokens = $this->getHunkStartTokens($diffLineList[$currentLine+2]);

        // In some cases we may have a diff with no contents (e.g. diff of svn propedit)
        if (count($hunkTokens)) {
            // Simple change
            if (4 == count($hunkTokens)) {
                $originalFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine]);
                $newFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine + 1]);

            // File deletion
            } elseif (Token::FILE_DELETION_LINE_COUNT === $hunkTokens[0]->getType()) {
                $originalFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine]);
                $newFilename = '';

            // File creation
            } else {
                $originalFilename = '';
                $newFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine + 1]);
            }

            $filenameTokens = [
                new Token(Token::ORIGINAL_FILENAME, $originalFilename),
                new Token(Token::NEW_FILENAME, $newFilename)
            ];
        }

        return $filenameTokens;
    }
private function getFilenameTokens(array $diffLineList, int $currentLine): array
    {
        $filenameTokens = [];

        // Get hunk metadata
        $hunkTokens = $this->getHunkStartTokens($diffLineList[$currentLine+2]);

        // In some cases we may have a diff with no contents (e.g. diff of svn propedit)
        if (count($hunkTokens)) {
            // Simple change
            if (4 == count($hunkTokens)) {
                $originalFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine]);
                $newFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine + 1]);

            // File deletion
            } elseif (Token::FILE_DELETION_LINE_COUNT === $hunkTokens[0]->getType()) {
                $originalFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine]);
                $newFilename = '';

            // File creation
            } else {
                $originalFilename = '';
                $newFilename = $this->diffNormalizer->getFilename($diffLineList[$currentLine + 1]);
            }

            $filenameTokens = [
                new Token(Token::ORIGINAL_FILENAME, $originalFilename),
                new Token(Token::NEW_FILENAME, $newFilename)
            ];
        }

        return $filenameTokens;
    }
private function getFilenameTokens ( array $ diffLineList , int $ currentLine ) : array { $ filenameTokens = [ ] ; // Get hunk metadata $ hunkTokens = $ this -> getHunkStartTokens ( $ diffLineList [ $ currentLine + 2 ] ) ; // In some cases we may have a diff with no contents (e.g. diff of svn propedit) if ( count ( $ hunkTokens ) ) { // Simple change if ( 4 == count ( $ hunkTokens ) ) { $ originalFilename = $ this -> diffNormalizer -> getFilename ( $ diffLineList [ $ currentLine ] ) ; $ newFilename = $ this -> diffNormalizer -> getFilename ( $ diffLineList [ $ currentLine + 1 ] ) ; // File deletion } elseif ( Token :: FILE_DELETION_LINE_COUNT === $ hunkTokens [ 0 ] -> getType ( ) ) { $ originalFilename = $ this -> diffNormalizer -> getFilename ( $ diffLineList [ $ currentLine ] ) ; $ newFilename = '' ; // File creation } else { $ originalFilename = '' ; $ newFilename = $ this -> diffNormalizer -> getFilename ( $ diffLineList [ $ currentLine + 1 ] ) ; } $ filenameTokens = [ new Token ( Token :: ORIGINAL_FILENAME , $ originalFilename ) , new Token ( Token :: NEW_FILENAME , $ newFilename ) ] ; } return $ filenameTokens ; }
Get tokens for original & new filenames.

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

@return Token[]
Get tokens for original & new filenames .