src/Language/Source.php
public function getLocation($position)
    {
        $line   = 1;
        $column = $position + 1;

        $utfChars   = json_decode('"\u2028\u2029"');
        $lineRegexp = '/\r\n|[\n\r' . $utfChars . ']/su';
        $matches    = [];
        preg_match_all($lineRegexp, mb_substr($this->body, 0, $position, 'UTF-8'), $matches, PREG_OFFSET_CAPTURE);

        foreach ($matches[0] as $index => $match) {
            $line += 1;

            $column = $position + 1 - ($match[1] + mb_strlen($match[0], 'UTF-8'));
        }

        return new SourceLocation($line, $column);
    }
public function getLocation($position)
    {
        $line   = 1;
        $column = $position + 1;

        $utfChars   = json_decode('"\u2028\u2029"');
        $lineRegexp = '/\r\n|[\n\r' . $utfChars . ']/su';
        $matches    = [];
        preg_match_all($lineRegexp, mb_substr($this->body, 0, $position, 'UTF-8'), $matches, PREG_OFFSET_CAPTURE);

        foreach ($matches[0] as $index => $match) {
            $line += 1;

            $column = $position + 1 - ($match[1] + mb_strlen($match[0], 'UTF-8'));
        }

        return new SourceLocation($line, $column);
    }
public function getLocation ( $ position ) { $ line = 1 ; $ column = $ position + 1 ; $ utfChars = json_decode ( '"\u2028\u2029"' ) ; $ lineRegexp = '/\r\n|[\n\r' . $ utfChars . ']/su' ; $ matches = [ ] ; preg_match_all ( $ lineRegexp , mb_substr ( $ this -> body , 0 , $ position , 'UTF-8' ) , $ matches , PREG_OFFSET_CAPTURE ) ; foreach ( $ matches [ 0 ] as $ index => $ match ) { $ line += 1 ; $ column = $ position + 1 - ( $ match [ 1 ] + mb_strlen ( $ match [ 0 ] , 'UTF-8' ) ) ; } return new SourceLocation ( $ line , $ column ) ; }
@param int $position

@return SourceLocation
@param int $position