src/Diff.php
private function parse(string $diff) : array
    {
        $diff = preg_split("/((\r?\n)|(\r\n?))/", $diff);
        $paths = [];
        $number = 0;
        $path = null;

        foreach ($diff as $line) {
            if (preg_match('~^\+\+\+\s(.*)~', $line, $matches)) {
                $path = substr($matches[1], strpos($matches[1], '/') + 1);
            } elseif (preg_match(
                '~^@@ -[0-9]+,[0-9]+? \+([0-9]+),[0-9]+? @@.*$~',
                $line,
                $matches
            )) {
                $number = (int) $matches[1];
            } elseif (preg_match('~^\+(.*)~', $line, $matches)) {
                $paths[$path][] = $number;
                $number++;
            } elseif (preg_match('~^[^-]+(.*)~', $line, $matches)) {
                $number++;
            }
        }

        return $paths;
    }
private function parse(string $diff) : array
    {
        $diff = preg_split("/((\r?\n)|(\r\n?))/", $diff);
        $paths = [];
        $number = 0;
        $path = null;

        foreach ($diff as $line) {
            if (preg_match('~^\+\+\+\s(.*)~', $line, $matches)) {
                $path = substr($matches[1], strpos($matches[1], '/') + 1);
            } elseif (preg_match(
                '~^@@ -[0-9]+,[0-9]+? \+([0-9]+),[0-9]+? @@.*$~',
                $line,
                $matches
            )) {
                $number = (int) $matches[1];
            } elseif (preg_match('~^\+(.*)~', $line, $matches)) {
                $paths[$path][] = $number;
                $number++;
            } elseif (preg_match('~^[^-]+(.*)~', $line, $matches)) {
                $number++;
            }
        }

        return $paths;
    }
private function parse ( string $ diff ) : array { $ diff = preg_split ( "/((\r?\n)|(\r\n?))/" , $ diff ) ; $ paths = [ ] ; $ number = 0 ; $ path = null ; foreach ( $ diff as $ line ) { if ( preg_match ( '~^\+\+\+\s(.*)~' , $ line , $ matches ) ) { $ path = substr ( $ matches [ 1 ] , strpos ( $ matches [ 1 ] , '/' ) + 1 ) ; } elseif ( preg_match ( '~^@@ -[0-9]+,[0-9]+? \+([0-9]+),[0-9]+? @@.*$~' , $ line , $ matches ) ) { $ number = ( int ) $ matches [ 1 ] ; } elseif ( preg_match ( '~^\+(.*)~' , $ line , $ matches ) ) { $ paths [ $ path ] [ ] = $ number ; $ number ++ ; } elseif ( preg_match ( '~^[^-]+(.*)~' , $ line , $ matches ) ) { $ number ++ ; } } return $ paths ; }
Parses diff and returns array containing affected paths and line numbers

@param string $diff Diff output

@return array
Parses diff and returns array containing affected paths and line numbers