src/Url.php
private static function myValidateFragment(?string $fragment, ?string &$error): bool
    {
        if ($fragment === null) {
            return true;
        }

        if (preg_match('/[^0-9a-zA-Z._~!\$&\'()*\+,;=:@\[\]\/\?%-]/', $fragment, $matches)) {
            $error = 'Fragment "' . $fragment . '" contains invalid character "' . $matches[0] . '".';

            return false;
        }

        return true;
    }
private static function myValidateFragment(?string $fragment, ?string &$error): bool
    {
        if ($fragment === null) {
            return true;
        }

        if (preg_match('/[^0-9a-zA-Z._~!\$&\'()*\+,;=:@\[\]\/\?%-]/', $fragment, $matches)) {
            $error = 'Fragment "' . $fragment . '" contains invalid character "' . $matches[0] . '".';

            return false;
        }

        return true;
    }
private static function myValidateFragment ( ? string $ fragment , ? string & $ error ) : bool { if ( $ fragment === null ) { return true ; } if ( preg_match ( '/[^0-9a-zA-Z._~!\$&\'()*\+,;=:@\[\]\/\?%-]/' , $ fragment , $ matches ) ) { $ error = 'Fragment "' . $ fragment . '" contains invalid character "' . $ matches [ 0 ] . '".' ; return false ; } return true ; }
Validates a fragment.

@param string|null $fragment The fragment.
@param string      $error    The error text if validation was not successful, undefined otherwise.

@return bool True if validation was successful, false otherwise.
Validates a fragment .