protected function parseToken(string $content): array
    {
        $token = [
            self::TOKEN_NAME       => '',
            self::TOKEN_TYPE       => self::TAG_OPEN,
            self::TOKEN_CONTENT    => '<' . ($content = $this->repairPHP($content)) . '>',
            self::TOKEN_ATTRIBUTES => []
        ];

        //Some parts of text just looks like tags, but their not
        if (!preg_match('/^\/?[a-z0-9_:\/][a-z 0-9\._\-:\/]*/i', $content)) {
            $token[self::TOKEN_TYPE] = self::PLAIN_TEXT;
            unset($token[self::TOKEN_NAME], $token[self::TOKEN_NAME]);

            return $token;
        }

        //Local PHP isolation
        $isolator = new Isolator('-argument-', '-block-');

        //No PHP blocks
        $content = $isolator->isolatePHP($content);

        //Parsing arguments, due they already checked for open-close quotas we can use regular expression
        $attribute = '/(?P<name>[a-z0-9_\-\.\:]+)[ \n\t\r]*(?:(?P<equal>=)[ \n\t\r]*'
            . '(?P<value>[a-z0-9\-]+|\'[^\']+\'|\"[^\"]+\"|\"\"))?/si';

        preg_match_all($attribute, $content, $attributes);

        foreach ($attributes['value'] as $index => $value) {
            if ($value && ($value{0} == "'" || $value{0} == '"')) {
                $value = trim($value, $value{0});
            }

            //Local and global php isolation restore
            $name = $this->repairPHP($isolator->repairPHP($attributes['name'][$index]));

            $token[self::TOKEN_ATTRIBUTES][$name] = $this->repairPHP($isolator->repairPHP($value));

            if (empty($attributes['equal'][$index])) {
                $token[self::TOKEN_ATTRIBUTES][$name] = null;
            }
        }

        //Fetching name
        $name = $isolator->repairPHP(current(explode(' ', $content)));
        if ($name{0} == '/') {
            $token[self::TOKEN_TYPE] = self::TAG_CLOSE;
            unset($token[self::TOKEN_ATTRIBUTES]);
        }

        if ($content{strlen($content) - 1} == '/') {
            $token[self::TOKEN_TYPE] = self::TAG_SHORT;
        }

        $token[self::TOKEN_NAME] = $name = trim($name, '/');
        unset($token[self::TOKEN_ATTRIBUTES][$name]);

        $token[self::TOKEN_NAME] = trim($token[self::TOKEN_NAME]);

        if (
            $token[self::TOKEN_TYPE] == self::TAG_OPEN
            && in_array($token[self::TOKEN_NAME], $this->voidTags)
        ) {
            $token[self::TOKEN_TYPE] = self::TAG_VOID;
        }

        return $token;
    }
protected function parseToken(string $content): array
    {
        $token = [
            self::TOKEN_NAME       => '',
            self::TOKEN_TYPE       => self::TAG_OPEN,
            self::TOKEN_CONTENT    => '<' . ($content = $this->repairPHP($content)) . '>',
            self::TOKEN_ATTRIBUTES => []
        ];

        //Some parts of text just looks like tags, but their not
        if (!preg_match('/^\/?[a-z0-9_:\/][a-z 0-9\._\-:\/]*/i', $content)) {
            $token[self::TOKEN_TYPE] = self::PLAIN_TEXT;
            unset($token[self::TOKEN_NAME], $token[self::TOKEN_NAME]);

            return $token;
        }

        //Local PHP isolation
        $isolator = new Isolator('-argument-', '-block-');

        //No PHP blocks
        $content = $isolator->isolatePHP($content);

        //Parsing arguments, due they already checked for open-close quotas we can use regular expression
        $attribute = '/(?P<name>[a-z0-9_\-\.\:]+)[ \n\t\r]*(?:(?P<equal>=)[ \n\t\r]*'
            . '(?P<value>[a-z0-9\-]+|\'[^\']+\'|\"[^\"]+\"|\"\"))?/si';

        preg_match_all($attribute, $content, $attributes);

        foreach ($attributes['value'] as $index => $value) {
            if ($value && ($value{0} == "'" || $value{0} == '"')) {
                $value = trim($value, $value{0});
            }

            //Local and global php isolation restore
            $name = $this->repairPHP($isolator->repairPHP($attributes['name'][$index]));

            $token[self::TOKEN_ATTRIBUTES][$name] = $this->repairPHP($isolator->repairPHP($value));

            if (empty($attributes['equal'][$index])) {
                $token[self::TOKEN_ATTRIBUTES][$name] = null;
            }
        }

        //Fetching name
        $name = $isolator->repairPHP(current(explode(' ', $content)));
        if ($name{0} == '/') {
            $token[self::TOKEN_TYPE] = self::TAG_CLOSE;
            unset($token[self::TOKEN_ATTRIBUTES]);
        }

        if ($content{strlen($content) - 1} == '/') {
            $token[self::TOKEN_TYPE] = self::TAG_SHORT;
        }

        $token[self::TOKEN_NAME] = $name = trim($name, '/');
        unset($token[self::TOKEN_ATTRIBUTES][$name]);

        $token[self::TOKEN_NAME] = trim($token[self::TOKEN_NAME]);

        if (
            $token[self::TOKEN_TYPE] == self::TAG_OPEN
            && in_array($token[self::TOKEN_NAME], $this->voidTags)
        ) {
            $token[self::TOKEN_TYPE] = self::TAG_VOID;
        }

        return $token;
    }
protected function parseToken ( string $ content ) : array { $ token = [ self :: TOKEN_NAME => '' , self :: TOKEN_TYPE => self :: TAG_OPEN , self :: TOKEN_CONTENT => '<' . ( $ content = $ this -> repairPHP ( $ content ) ) . '>' , self :: TOKEN_ATTRIBUTES => [ ] ] ; //Some parts of text just looks like tags, but their not if ( ! preg_match ( '/^\/?[a-z0-9_:\/][a-z 0-9\._\-:\/]*/i' , $ content ) ) { $ token [ self :: TOKEN_TYPE ] = self :: PLAIN_TEXT ; unset ( $ token [ self :: TOKEN_NAME ] , $ token [ self :: TOKEN_NAME ] ) ; return $ token ; } //Local PHP isolation $ isolator = new Isolator ( '-argument-' , '-block-' ) ; //No PHP blocks $ content = $ isolator -> isolatePHP ( $ content ) ; //Parsing arguments, due they already checked for open-close quotas we can use regular expression $ attribute = '/(?P<name>[a-z0-9_\-\.\:]+)[ \n\t\r]*(?:(?P<equal>=)[ \n\t\r]*' . '(?P<value>[a-z0-9\-]+|\'[^\']+\'|\"[^\"]+\"|\"\"))?/si' ; preg_match_all ( $ attribute , $ content , $ attributes ) ; foreach ( $ attributes [ 'value' ] as $ index => $ value ) { if ( $ value && ( $ value { 0 } == "'" || $ value { 0 } == '"' ) ) { $ value = trim ( $ value , $ value { 0 } ) ; } //Local and global php isolation restore $ name = $ this -> repairPHP ( $ isolator -> repairPHP ( $ attributes [ 'name' ] [ $ index ] ) ) ; $ token [ self :: TOKEN_ATTRIBUTES ] [ $ name ] = $ this -> repairPHP ( $ isolator -> repairPHP ( $ value ) ) ; if ( empty ( $ attributes [ 'equal' ] [ $ index ] ) ) { $ token [ self :: TOKEN_ATTRIBUTES ] [ $ name ] = null ; } } //Fetching name $ name = $ isolator -> repairPHP ( current ( explode ( ' ' , $ content ) ) ) ; if ( $ name { 0 } == '/' ) { $ token [ self :: TOKEN_TYPE ] = self :: TAG_CLOSE ; unset ( $ token [ self :: TOKEN_ATTRIBUTES ] ) ; } if ( $ content { strlen ( $ content ) - 1 } == '/' ) { $ token [ self :: TOKEN_TYPE ] = self :: TAG_SHORT ; } $ token [ self :: TOKEN_NAME ] = $ name = trim ( $ name , '/' ) ; unset ( $ token [ self :: TOKEN_ATTRIBUTES ] [ $ name ] ) ; $ token [ self :: TOKEN_NAME ] = trim ( $ token [ self :: TOKEN_NAME ] ) ; if ( $ token [ self :: TOKEN_TYPE ] == self :: TAG_OPEN && in_array ( $ token [ self :: TOKEN_NAME ] , $ this -> voidTags ) ) { $ token [ self :: TOKEN_TYPE ] = self :: TAG_VOID ; } return $ token ; }
Parses tag body for arguments, name, etc.

@param string $content Tag content to be parsed (from < till >).

@return array
Parses tag body for arguments name etc .