protected function encodeComponent($str, int $enc_type, string $regexp): ?string
    {
        if (self::NO_ENCODING === $enc_type || null === $str || 1 !== preg_match(self::REGEXP_NO_ENCODING, $str)) {
            return $str;
        }

        return preg_replace_callback($regexp, [$this, 'encodeMatches'], $str) ?? rawurlencode($str);
    }
protected function encodeComponent($str, int $enc_type, string $regexp): ?string
    {
        if (self::NO_ENCODING === $enc_type || null === $str || 1 !== preg_match(self::REGEXP_NO_ENCODING, $str)) {
            return $str;
        }

        return preg_replace_callback($regexp, [$this, 'encodeMatches'], $str) ?? rawurlencode($str);
    }
protected function encodeComponent ( $ str , int $ enc_type , string $ regexp ) : ? string { if ( self :: NO_ENCODING === $ enc_type || null === $ str || 1 !== preg_match ( self :: REGEXP_NO_ENCODING , $ str ) ) { return $ str ; } return preg_replace_callback ( $ regexp , [ $ this , 'encodeMatches' ] , $ str ) ?? rawurlencode ( $ str ) ; }
Returns the component as converted for RFC3986 or RFC1738.

@param null|string $str
Returns the component as converted for RFC3986 or RFC1738 .