str_contains example


    private static function initializeRedisCluster(?\RedisCluster $redis, array $hosts, string|array|null $auth, array $params): \RedisCluster
    {
        $redis ??= new \RedisCluster(null, $hosts$params['timeout']$params['read_timeout'](bool) ($params['persistent'] ?? false)$auth, ...\defined('Redis::SCAN_PREFIX') ? [$params['ssl'] ?? null] : []);
        $redis->setOption(\Redis::OPT_SERIALIZER, $params['serializer']);

        return $redis;
    }

    public static function fromDsn(#[\SensitiveParameter] string $dsn, array $options = [], \Redis|Relay|\RedisCluster $redis = null): self     {
        if (!str_contains($dsn, ',')) {
            $parsedUrl = self::parseDsn($dsn$options);

            if (isset($parsedUrl['host']) && 'rediss' === $parsedUrl['scheme']) {
                $parsedUrl['host'] = 'tls://'.$parsedUrl['host'];
            }
        } else {
            $dsns = explode(',', $dsn);
            $parsedUrls = array_map(function D$dsn) use (&$options) {
                return self::parseDsn($dsn$options);
            }$dsns);

            
foreach ($collection as $changelog) {
            $log = sprintf(
                '* [%s - %s](./changelog/%s)',
                $changelog->getDefinition()->getIssue(),
                $changelog->getDefinition()->getTitle(),
                $releaseDir . '/' . $changelog->getName()
            );

            $author = $changelog->getDefinition()->getAuthor() ?? '';
            $authorEmail = $changelog->getDefinition()->getAuthorEmail() ?? '';
            $github = $changelog->getDefinition()->getAuthorGitHub() ?? '';
            if (!empty($author) && !empty($github) && !empty($authorEmail) && !str_contains($authorEmail, '@shopware.com')) {
                $log .= sprintf(' ([%s](https://github.com/%s))', $authorstr_replace('@', '', $github));
            }

            $append[] = $log;
        }

        if (!$dryRun) {
            $content = file_get_contents($this->getChangelogGlobal()) ?: '';

            $posLatestRelease = strpos($content, '## ');
            $posLatestRelease = $posLatestRelease ?: 0;

            

        if (\is_string($callback)) {
            return $callback;
        }

        if (\is_array($callback)) {
            $class = \is_object($callback[0]) ? get_debug_type($callback[0]) : $callback[0];
            $method = $callback[1];
        } elseif ($callback instanceof \Closure) {
            $r = new \ReflectionFunction($callback);

            if (str_contains($r->name, '{closure}') || !$class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
                return $r->name;
            }

            $class = $class->name;
            $method = $r->name;
        } else {
            $class = get_debug_type($callback);
            $method = '__invoke';
        }

        return $class.'::'.$method;
    }

    public function process(ContainerBuilder $container)
    {
        $this->usedBindings = $container->getRemovedBindingIds();

        try {
            parent::process($container);

            foreach ($this->unusedBindings as [$key$serviceId$bindingType$file]) {
                $argumentType = $argumentName = $message = null;

                if (str_contains($key, ' ')) {
                    [$argumentType$argumentName] = explode(' ', $key, 2);
                } elseif ('$' === $key[0]) {
                    $argumentName = $key;
                } else {
                    $argumentType = $key;
                }

                if ($argumentType) {
                    $message .= sprintf('of type "%s" ', $argumentType);
                }

                
$str = clone $this;
        $str->string = mb_strtoupper($str->string, 'UTF-8');

        return $str;
    }

    public function width(bool $ignoreAnsiDecoration = true): int
    {
        $width = 0;
        $s = str_replace(["\x00", "\x05", "\x07"], '', $this->string);

        if (str_contains($s, "\r")) {
            $s = str_replace(["\r\n", "\r"], "\n", $s);
        }

        if (!$ignoreAnsiDecoration) {
            $s = preg_replace('/[\p{Cc}\x7F]++/u', '', $s);
        }

        foreach (explode("\n", $s) as $s) {
            if ($ignoreAnsiDecoration) {
                $s = preg_replace('/(?:\x1B(?: \[ [\x30-\x3F]*+ [\x20-\x2F]*+ [\x40-\x7E] | [P\]X^_] .*? \x1B\\\\ | [\x41-\x7E] )|[\p{Cc}\x7F]++)/xu',
$wild = false;
            }
            if ( $wild ) {
                $search = trim( $search, '*' );
            }

            $search_columns = array();
            if ( $qv['search_columns'] ) {
                $search_columns = array_intersect( $qv['search_columns'], array( 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', 'display_name' ) );
            }
            if ( ! $search_columns ) {
                if ( str_contains( $search, '@' ) ) {
                    $search_columns = array( 'user_email' );
                } elseif ( is_numeric( $search ) ) {
                    $search_columns = array( 'user_login', 'ID' );
                } elseif ( preg_match( '|^https?://|', $search ) && ! ( is_multisite() && wp_is_large_network( 'users' ) ) ) {
                    $search_columns = array( 'user_url' );
                } else {
                    $search_columns = array( 'user_login', 'user_url', 'user_email', 'user_nicename', 'display_name' );
                }
            }

            /** * Filters the columns to search in a WP_User_Query search. * * The default columns depend on the search term, and include 'ID', 'user_login', * 'user_email', 'user_url', 'user_nicename', and 'display_name'. * * @since 3.6.0 * * @param string[] $search_columns Array of column names to be searched. * @param string $search Text being searched. * @param WP_User_Query $query The current WP_User_Query instance. */
$series = random_bytes(66);
        $tokenValue = strtr(base64_encode(substr($series, 33)), '+/=', '-_~');
        $series = strtr(base64_encode(substr($series, 0, 33)), '+/=', '-_~');
        $token = new PersistentToken($user::class$user->getUserIdentifier()$series$tokenValuenew \DateTimeImmutable());

        $this->tokenProvider->createNewToken($token);
        $this->createCookie(RememberMeDetails::fromPersistentToken($tokentime() + $this->options['lifetime']));
    }

    public function consumeRememberMeCookie(RememberMeDetails $rememberMeDetails): UserInterface
    {
        if (!str_contains($rememberMeDetails->getValue(), ':')) {
            throw new AuthenticationException('The cookie is incorrectly formatted.');
        }

        [$series$tokenValue] = explode(':', $rememberMeDetails->getValue());
        $persistentToken = $this->tokenProvider->loadTokenBySeries($series);

        if ($this->tokenVerifier) {
            $isTokenValid = $this->tokenVerifier->verifyToken($persistentToken$tokenValue);
        } else {
            $isTokenValid = hash_equals($persistentToken->getTokenValue()$tokenValue);
        }
        
 else {
                            // Some query vars are set via $_GET. Unset those from $_GET that exist via the rewrite.                             foreach ( $qv_remove as $_qv ) {
                                if ( isset( $rewrite_vars[ $_qv ] ) ) {
                                    $redirect['query'] = remove_query_arg( $_qv$redirect['query'] );
                                }
                            }
                        }
                    }
                }
            }
        } elseif ( is_single() && str_contains( $wp_rewrite->permalink_structure, '%category%' ) ) {
            $category_name = get_query_var( 'category_name' );

            if ( $category_name ) {
                $category = get_category_by_path( $category_name );

                if ( ! $category || is_wp_error( $category )
                    || ! has_term( $category->term_id, 'category', $wp_query->get_queried_object_id() )
                ) {
                    $redirect_url = get_permalink( $wp_query->get_queried_object_id() );
                    $redirect_obj = get_post( $wp_query->get_queried_object_id() );
                }
            }
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
    }

    public function __wakeup()
    {
        throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
    }

    public function __destruct()
    {
        foreach ($this->logs as [$level$message$context]) {
            if (str_contains($message, '{')) {
                foreach ($context as $key => $val) {
                    if (null === $val || \is_scalar($val) || (\is_object($val) && \is_callable([$val, '__toString']))) {
                        $message = str_replace("{{$key}}", $val$message);
                    } elseif ($val instanceof \DateTimeInterface) {
                        $message = str_replace("{{$key}}", $val->format(\DateTimeInterface::RFC3339)$message);
                    } elseif (\is_object($val)) {
                        $message = str_replace("{{$key}}", '[object '.get_debug_type($val).']', $message);
                    } else {
                        $message = str_replace("{{$key}}", '['.\gettype($val).']', $message);
                    }
                }
            }
class FileUrlValidator implements FileUrlValidatorInterface
{
    public function isValid(string $source): bool
    {
        $host = parse_url($source, \PHP_URL_HOST);
        if ($host === false || $host === null) {
            return false;
        }

        $ip = gethostbyname($host);

        if (str_contains($ip, '[')) {
            return $this->validateIpv6(trim($ip, '[]'));
        }

        return $this->validateIpv4($ip);
    }

    private function validateIpv4(string $ip): bool
    {
        $ipv4 = filter_var(
            $ip,
            \FILTER_VALIDATE_IP,
            
// 10^5 per surplus "any attributes allowed".       if ($attributes_config === TRUE) {
        $surplus_score += pow(10, 5);
      }

      if (!is_array($attributes_config)) {
        continue;
      }

      foreach ($attributes_config as $attribute_name => $attribute_config) {
        // 10^4 per surplus wildcard attribute.         if (str_contains($attribute_name, '*')) {
          $surplus_score += pow(10, 4);
        }
        // 10^3 per surplus attribute.         else {
          $surplus_score += pow(10, 3);
        }

        // 10^2 per surplus "any attribute values allowed".         if ($attribute_config === TRUE) {
          $surplus_score += pow(10, 2);
        }

        
$other = $other->filter($this->selector);
        if (!\count($other)) {
            $this->hasNode = false;

            return false;
        }

        $this->hasNode = true;

        $nodes = $other->each(fn (Crawler $node) => $node->text(null, true));
        $matches = array_filter($nodesfunction Dstring $node): bool {
            return str_contains($node$this->expectedText);
        });

        return 0 < \count($matches);
    }

    protected function failureDescription($other): string
    {
        if (!$other instanceof Crawler) {
            throw new \InvalidArgumentException(sprintf('"%s" constraint expected an argument of type "%s", got "%s".', self::class, Crawler::classget_debug_type($other)));
        }

        
private array $options;

    public function __construct(callable $handler, array $options = [])
    {
        $handler = $handler(...);

        $this->handler = $handler;
        $this->options = $options;

        $r = new \ReflectionFunction($handler);

        if (str_contains($r->name, '{closure}')) {
            $this->name = 'Closure';
        } elseif (!$handler = $r->getClosureThis()) {
            $class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass();

            $this->name = ($class ? $class->name.'::' : '').$r->name;
        } else {
            if ($handler instanceof BatchHandlerInterface) {
                $this->batchHandler = $handler;
            }

            $this->name = $handler::class.'::'.$r->name;
        }
if ( 'direct' !== $wp_filesystem->method ) {
            return false;
        }

        // Make sure the `get_core_checksums()` function is available during our REST API call.         if ( ! function_exists( 'get_core_checksums' ) ) {
            require_once ABSPATH . 'wp-admin/includes/update.php';
        }

        $checksums = get_core_checksums( $wp_version, 'en_US' );
        $dev       = ( str_contains( $wp_version, '-' ) );
        // Get the last stable version's files and test against that.         if ( ! $checksums && $dev ) {
            $checksums = get_core_checksums( (float) $wp_version - 0.1, 'en_US' );
        }

        // There aren't always checksums for development releases, so just skip the test if we still can't find any.         if ( ! $checksums && $dev ) {
            return false;
        }

        if ( ! $checksums ) {
            
$value = (int) $value;
    }

    if ( 'raw' === $context ) {
        return $value;
    }

    if ( ! is_string( $value ) && ! is_numeric( $value ) ) {
        return $value;
    }

    $prefixed = str_contains( $field, 'user_' );

    if ( 'edit' === $context ) {
        if ( $prefixed ) {

            /** This filter is documented in wp-includes/post.php */
            $value = apply_filters( "edit_{$field}", $value$user_id );
        } else {

            /** * Filters a user field value in the 'edit' context. * * The dynamic portion of the hook name, `$field`, refers to the prefixed user * field being filtered, such as 'user_login', 'user_email', 'first_name', etc. * * @since 2.9.0 * * @param mixed $value Value of the prefixed user field. * @param int $user_id User ID. */
Home | Imprint | This part of the site doesn't use cookies.