private static function validateRegExp(string $regExp, string $displayName): void
    {
        /** @uses convertErrorToException() */
        set_error_handler([__CLASS__, 'convertErrorToException'], E_WARNING);
        try {
            if (false === preg_match($regExp, null)) {
                throw new \InvalidArgumentException(
                    "PCRE error in $displayName RegExp: $regExp",
                    preg_last_error()
                );
            }
        } catch (\ErrorException $e) {
            throw new \InvalidArgumentException(
                "PCRE error in $displayName RegExp: " . $e->getMessage() . "; RegExp: $regExp",
                preg_last_error(),
                $e
            );
        } finally {
            restore_error_handler();
        }
    }
private static function validateRegExp(string $regExp, string $displayName): void
    {
        /** @uses convertErrorToException() */
        set_error_handler([__CLASS__, 'convertErrorToException'], E_WARNING);
        try {
            if (false === preg_match($regExp, null)) {
                throw new \InvalidArgumentException(
                    "PCRE error in $displayName RegExp: $regExp",
                    preg_last_error()
                );
            }
        } catch (\ErrorException $e) {
            throw new \InvalidArgumentException(
                "PCRE error in $displayName RegExp: " . $e->getMessage() . "; RegExp: $regExp",
                preg_last_error(),
                $e
            );
        } finally {
            restore_error_handler();
        }
    }
private static function validateRegExp ( string $ regExp , string $ displayName ) : void { /** @uses convertErrorToException() */ set_error_handler ( [ __CLASS__ , 'convertErrorToException' ] , E_WARNING ) ; try { if ( false === preg_match ( $ regExp , null ) ) { throw new \ InvalidArgumentException ( "PCRE error in $displayName RegExp: $regExp" , preg_last_error ( ) ) ; } } catch ( \ ErrorException $ e ) { throw new \ InvalidArgumentException ( "PCRE error in $displayName RegExp: " . $ e -> getMessage ( ) . "; RegExp: $regExp" , preg_last_error ( ) , $ e ) ; } finally { restore_error_handler ( ) ; } }
Validate given RegExp
@param string $regExp RegExp to validate
@param string $displayName Display name for error message
@throws \InvalidArgumentException
Validate given RegExp