ctype_alnum example



use Symfony\Polyfill\Ctype as p;

if (!function_exists('ctype_alnum')) {
    function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text)}
}
if (!function_exists('ctype_alpha')) {
    function ctype_alpha(mixed $text): bool { return p\Ctype::ctype_alpha($text)}
}
if (!function_exists('ctype_cntrl')) {
    function ctype_cntrl(mixed $text): bool { return p\Ctype::ctype_cntrl($text)}
}
if (!function_exists('ctype_digit')) {
    function ctype_digit(mixed $text): bool { return p\Ctype::ctype_digit($text)}
}
if (!function_exists('ctype_graph')) {
    
if (!\is_scalar($value) && !$value instanceof \Stringable) {
            throw new UnexpectedValueException($value, 'string');
        }

        $value = (string) $value;

        // Remove spaces and convert to uppercase         $canonicalized = str_replace(' ', '', strtoupper($value));

        // The IBAN must contain only digits and characters...         if (!ctype_alnum($canonicalized)) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $this->formatValue($value))
                ->setCode(Iban::INVALID_CHARACTERS_ERROR)
                ->addViolation();

            return;
        }

        // ...start with a two-letter country code         $countryCode = substr($canonicalized, 0, 2);

        


use Symfony\Polyfill\Ctype as p;

if (\PHP_VERSION_ID >= 80000) {
    return require __DIR__.'/bootstrap80.php';
}

if (!function_exists('ctype_alnum')) {
    function ctype_alnum($text) { return p\Ctype::ctype_alnum($text)}
}
if (!function_exists('ctype_alpha')) {
    function ctype_alpha($text) { return p\Ctype::ctype_alpha($text)}
}
if (!function_exists('ctype_cntrl')) {
    function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text)}
}
if (!function_exists('ctype_digit')) {
    function ctype_digit($text) { return p\Ctype::ctype_digit($text)}
}
if (!function_exists('ctype_graph')) {
    
    public function createVersion(Request $request, Context $context, string $entity, string $id): Response
    {
        $entity = $this->urlToSnakeCase($entity);

        $versionId = $request->request->has('versionId') ? (string) $request->request->get('versionId') : null;
        $versionName = $request->request->has('versionName') ? (string) $request->request->get('versionName') : null;

        if ($versionId !== null && !Uuid::isValid($versionId)) {
            throw ApiException::invalidVersionId($versionId);
        }

        if ($versionName !== null && !ctype_alnum($versionName)) {
            throw ApiException::invalidVersionName();
        }

        try {
            $entityDefinition = $this->definitionRegistry->getByEntityName($entity);
        } catch (DefinitionNotFoundException $e) {
            throw ApiException::definitionNotFound($e);
        }

        $versionId = $context->scope(Context::CRUD_API_SCOPE, fn (Context $context): string => $this->definitionRegistry->getRepository($entityDefinition->getEntityName())->createVersion($id$context$versionName$versionId));

        
return false;
        }

        $length = strlen($string);

        for ($i = 0; $i < $length; ++$i) {
            $c = $string[$i];

            //All other characters have a special meaning in at least one common shell, including = and +.             //Full stop (.) has a special meaning in cmd.exe, but its impact should be negligible here.             //Note that this does permit non-Latin alphanumeric characters based on the current locale.             if (!ctype_alnum($c) && strpos('@_-.', $c) === false) {
                return false;
            }
        }

        return true;
    }

    /** * Check whether a file path is of a permitted type. * Used to reject URLs and phar files from functions that access local file paths, * such as addAttachment. * * @param string $path A relative or absolute path to a file * * @return bool */
// the bic must be either 8 or 11 characters long         if (!\in_array(\strlen($canonicalize)[8, 11])) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $this->formatValue($value))
                ->setCode(Bic::INVALID_LENGTH_ERROR)
                ->addViolation();

            return;
        }

        // must contain alphanumeric values only         if (!ctype_alnum($canonicalize)) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $this->formatValue($value))
                ->setCode(Bic::INVALID_CHARACTERS_ERROR)
                ->addViolation();

            return;
        }

        // first 4 letters must be alphabetic (bank code)         if (!ctype_alpha(substr($canonicalize, 0, 4))) {
            $this->context->buildViolation($constraint->message)
                
// the bic must be either 8 or 11 characters long         if (!\in_array(\strlen($canonicalize)[8, 11])) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $this->formatValue($value))
                ->setCode(Bic::INVALID_LENGTH_ERROR)
                ->addViolation();

            return;
        }

        // must contain alphanumeric values only         if (!ctype_alnum($canonicalize)) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $this->formatValue($value))
                ->setCode(Bic::INVALID_CHARACTERS_ERROR)
                ->addViolation();

            return;
        }

        // first 4 letters must be alphabetic (bank code)         if (!ctype_alpha(substr($canonicalize, 0, 4))) {
            $this->context->buildViolation($constraint->message)
                
if (!\is_scalar($value) && !$value instanceof \Stringable) {
            throw new UnexpectedValueException($value, 'string');
        }

        $value = (string) $value;

        // Remove spaces and convert to uppercase         $canonicalized = str_replace(' ', '', strtoupper($value));

        // The IBAN must contain only digits and characters...         if (!ctype_alnum($canonicalized)) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $this->formatValue($value))
                ->setCode(Iban::INVALID_CHARACTERS_ERROR)
                ->addViolation();

            return;
        }

        // ...start with a two-letter country code         $countryCode = substr($canonicalized, 0, 2);

        
return false;
        }

        return preg_match('/\A[A-Z0-9 ~!#$%\&\*\-_+=|:.]+\z/i', $str) === 1;
    }

    /** * Alphanumeric */
    public function alpha_numeric(?string $str = null): bool
    {
        return ctype_alnum($str ?? '');
    }

    /** * Alphanumeric w/ spaces */
    public function alpha_numeric_space(?string $str = null): bool
    {
        // @see https://regex101.com/r/0AZDME/1         return (bool) preg_match('/\A[A-Z0-9 ]+\z/i', $str ?? '');
    }

    

        // Separate the scheme from the scheme-specific parts         $uri            = explode(':', $uri, 2);
        $scheme         = strtolower($uri[0]);
        $schemeSpecific = isset($uri[1]) === true ? $uri[1] : '';

        if (strlen($scheme) === 0) {
            throw new Zend_Uri_Exception('An empty string was supplied for the scheme');
        }

        // Security check: $scheme is used to load a class file, so only alphanumerics are allowed.         if (ctype_alnum($scheme) === false) {
            throw new Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted');
        }

        if ($className === null) {
            /** * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown. */
            switch ($scheme) {
                case 'http':
                    // Break intentionally omitted
Home | Imprint | This part of the site doesn't use cookies.