public function tokenize(string $value): array
    {
        $value = preg_replace(
            '/(.*?)<((?:.*?:)?(?:\p{L}|_|[0-9])+?)\((.*?)/',
            sprintf('$1%1$sFUNCTION_START__$2__%1$s$3', self::DELIMITER),
            $value
        );
        $value = preg_replace(
            '/<\(/',
            sprintf('%1$sIDENTITY_START%1$s', self::DELIMITER),
            $value
        );
        $value = preg_replace(
            '/\)>/',
            sprintf('%1$sIDENTITY_OR_FUNCTION_END%1$s', self::DELIMITER),
            $value
        );

        return preg_split(sprintf('/%s/', self::DELIMITER), $value, -1, PREG_SPLIT_NO_EMPTY);
    }
public function tokenize(string $value): array
    {
        $value = preg_replace(
            '/(.*?)<((?:.*?:)?(?:\p{L}|_|[0-9])+?)\((.*?)/',
            sprintf('$1%1$sFUNCTION_START__$2__%1$s$3', self::DELIMITER),
            $value
        );
        $value = preg_replace(
            '/<\(/',
            sprintf('%1$sIDENTITY_START%1$s', self::DELIMITER),
            $value
        );
        $value = preg_replace(
            '/\)>/',
            sprintf('%1$sIDENTITY_OR_FUNCTION_END%1$s', self::DELIMITER),
            $value
        );

        return preg_split(sprintf('/%s/', self::DELIMITER), $value, -1, PREG_SPLIT_NO_EMPTY);
    }
public function tokenize ( string $ value ) : array { $ value = preg_replace ( '/(.*?)<((?:.*?:)?(?:\p{L}|_|[0-9])+?)\((.*?)/' , sprintf ( '$1%1$sFUNCTION_START__$2__%1$s$3' , self :: DELIMITER ) , $ value ) ; $ value = preg_replace ( '/<\(/' , sprintf ( '%1$sIDENTITY_START%1$s' , self :: DELIMITER ) , $ value ) ; $ value = preg_replace ( '/\)>/' , sprintf ( '%1$sIDENTITY_OR_FUNCTION_END%1$s' , self :: DELIMITER ) , $ value ) ; return preg_split ( sprintf ( '/%s/' , self :: DELIMITER ) , $ value , - 1 , PREG_SPLIT_NO_EMPTY ) ; }
Replaces the function delimiters by tokens to easily identify them in the future and return the value splat into
tokens.

Example:
'foo <f(<g()>)> bar'
will result in:
[
'foo ',
'FUNCTION_START__f__',
'FUNCTION_START__g__',
'IDENTITY_OR_FUNCTION_END',
'IDENTITY_OR_FUNCTION_END',
' bar',
]
Replaces the function delimiters by tokens to easily identify them in the future and return the value splat into tokens .