src/Language/Lexer.php
private function readChar($advance = false, $byteStreamPosition = null)
    {
        if ($byteStreamPosition === null) {
            $byteStreamPosition = $this->byteStreamPosition;
        }

        $code           = null;
        $utf8char       = '';
        $bytes          = 0;
        $positionOffset = 0;

        if (isset($this->source->body[$byteStreamPosition])) {
            $ord = ord($this->source->body[$byteStreamPosition]);

            if ($ord < 128) {
                $bytes = 1;
            } elseif ($ord < 224) {
                $bytes = 2;
            } elseif ($ord < 240) {
                $bytes = 3;
            } else {
                $bytes = 4;
            }

            $utf8char = '';
            for ($pos = $byteStreamPosition; $pos < $byteStreamPosition + $bytes; $pos++) {
                $utf8char .= $this->source->body[$pos];
            }
            $positionOffset = 1;
            $code           = $bytes === 1 ? $ord : Utils::ord($utf8char);
        }

        if ($advance) {
            $this->moveStringCursor($positionOffset, $bytes);
        }

        return [$utf8char, $code, $bytes];
    }
private function readChar($advance = false, $byteStreamPosition = null)
    {
        if ($byteStreamPosition === null) {
            $byteStreamPosition = $this->byteStreamPosition;
        }

        $code           = null;
        $utf8char       = '';
        $bytes          = 0;
        $positionOffset = 0;

        if (isset($this->source->body[$byteStreamPosition])) {
            $ord = ord($this->source->body[$byteStreamPosition]);

            if ($ord < 128) {
                $bytes = 1;
            } elseif ($ord < 224) {
                $bytes = 2;
            } elseif ($ord < 240) {
                $bytes = 3;
            } else {
                $bytes = 4;
            }

            $utf8char = '';
            for ($pos = $byteStreamPosition; $pos < $byteStreamPosition + $bytes; $pos++) {
                $utf8char .= $this->source->body[$pos];
            }
            $positionOffset = 1;
            $code           = $bytes === 1 ? $ord : Utils::ord($utf8char);
        }

        if ($advance) {
            $this->moveStringCursor($positionOffset, $bytes);
        }

        return [$utf8char, $code, $bytes];
    }
private function readChar ( $ advance = false , $ byteStreamPosition = null ) { if ( $ byteStreamPosition === null ) { $ byteStreamPosition = $ this -> byteStreamPosition ; } $ code = null ; $ utf8char = '' ; $ bytes = 0 ; $ positionOffset = 0 ; if ( isset ( $ this -> source -> body [ $ byteStreamPosition ] ) ) { $ ord = ord ( $ this -> source -> body [ $ byteStreamPosition ] ) ; if ( $ ord < 128 ) { $ bytes = 1 ; } elseif ( $ ord < 224 ) { $ bytes = 2 ; } elseif ( $ ord < 240 ) { $ bytes = 3 ; } else { $ bytes = 4 ; } $ utf8char = '' ; for ( $ pos = $ byteStreamPosition ; $ pos < $ byteStreamPosition + $ bytes ; $ pos ++ ) { $ utf8char .= $ this -> source -> body [ $ pos ] ; } $ positionOffset = 1 ; $ code = $ bytes === 1 ? $ ord : Utils :: ord ( $ utf8char ) ; } if ( $ advance ) { $ this -> moveStringCursor ( $ positionOffset , $ bytes ) ; } return [ $ utf8char , $ code , $ bytes ] ; }
Reads next UTF8Character from the byte stream, starting from $byteStreamPosition.

@param bool $advance
@param int  $byteStreamPosition

@return (string|int)[]
Reads next UTF8Character from the byte stream starting from $byteStreamPosition .