Builds a default validator instance. Accepts an optional pre-fetch
hook.

@see Resolver::setPreFetchHook

@param Closure $preFetchHook

@return Validator
967601
public static function buildDefault(Closure $preFetchHook = null)
    {
        $registry = new Registry();
        $resolver = new Resolver();

        if ($preFetchHook) {
            $resolver->setPreFetchHook($preFetchHook);
        }

        $walker = new Walker($registry, $resolver);

        return new self($walker);
    }
1211746
public function then(\Closure $callback)
    {
        if ($this->ready) {
            return null;
        }

        $this->ready = true;

        if (!$this->checkDomain() || !$this->checkPath() || !$this->checkSecurity()) {
            return null;
        }

        $oNS = parent::$prefixNS;
        $oPP = parent::$prefixPath;

        if ($this->ns) {
            parent::$prefixNS = $this->ns;
        }

        if ($this->path) {
            parent::$prefixPath = rtrim($this->currentPrefixPath, '/');
        }

        call_user_func_array($callback, $this->arguments);

        parent::$prefixNS = $oNS;
        parent::$prefixPath = $oPP;
    }
384504
public function rememberForever($key, Closure $callback)
    {
        if (is_array($key)) {
            return $this->rememberManyForever($key, $callback);
        }

        return parent::rememberForever($key, $callback);
    }
1339172
public function preDispatch()
    {
        if ($this->getRequest()->getParam('filter_cookies')) {
            $this->_getHelper()->disableSessionForControllerAction('handle', $this);
        }

        return parent::preDispatch();
    }
267603
private function withReadPreference($object, \Closure $closure)
    {
        if ( ! isset($this->query['readPreference'])) {
            return $closure();
        }

        $prevReadPref = $object->getReadPreference();
        $object->setReadPreference($this->query['readPreference'], $this->query['readPreferenceTags']);

        try {
            $result = $closure();
        } catch (\Exception $e) {
        }

        $prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : null;
        $object->setReadPreference($prevReadPref['type'], $prevTags);

        if (isset($e)) {
            throw $e;
        }

        return $result;
    }
777979
def register_preloop_hook(self, func: Callable[[None], None]) -> None:
        """"""
        self._validate_prepostloop_callable(func)
        self._preloop_hooks.append(func)
449519
public static function create(Validator $validator = null): self
    {
        return new self(
            new ClosureContainer(
                [
                    'rollerworks_search.input.json' => function () use ($validator) {
                        return new Input\JsonInput($validator);
                    },
                    'rollerworks_search.input.string_query' => function () use ($validator) {
                        return new Input\StringQueryInput($validator);
                    },
                    'rollerworks_search.input.norm_string_query' => function () use ($validator) {
                        return new Input\NormStringQueryInput($validator);
                    },
                ]
            ),
            [
                'json' => 'rollerworks_search.input.json',
                'string_query' => 'rollerworks_search.input.string_query',
                'norm_string_query' => 'rollerworks_search.input.norm_string_query',
            ]
        );
    }
145850
public function beforeDetach()
    {
        $handler = $this->get('handler');
        if (class_exists($handler)) {
            $handler = new $handler();

            return $handler->beforeDetach($this);
        }
    }
46250
public function setQueryBuilderInitializer(\Closure $initializer = null)
    {
        if (!is_null($initializer)) {
            $this->validateQueryBuilderInitializer($initializer);
        }

        $this->queryBuilderInitializer = $initializer;

        return $this;
    }
1240951
protected function retry(\Closure $retry)
    {
        if ($this->numRetries < 1) {
            return $retry();
        }

        $firstException = null;

        for ($i = 0; $i <= $this->numRetries; $i++) {
            try {
                return $retry();
            } catch (\RiakCursorException $e) {
            } catch (\RiakConnectionException $e) {
            }

            if ($firstException === null) {
                $firstException = $e;
            }
            if ($i === $this->numRetries) {
                throw $firstException;
            }
        }
    }
1110595
public function afterEach(\Closure $closure)
    {
        $key = 'afterEach';
        $afterEach = new Hook($key, $closure, $this->current);
        $this->current->setHook($key, $afterEach);
    }
161928
public function preHook($hookName, $cb) {
		$args = [$hookName, $cb];
		return call_user_func_array([$this->getHookManager(), 'preHook'], $args);
	}
240234
public function getCredentialsFetcher()
    {
        $fetcher = null;

        if ($this->credentialsFetcher) {
            $fetcher = $this->credentialsFetcher;
        } elseif ($this->keyFile) {
            $fetcher = CredentialsLoader::makeCredentials($this->scopes, $this->keyFile);
        } else {
            try {
                $fetcher = $this->getADC();
            } catch (\DomainException $ex) {
                $fetcher = new AnonymousCredentials();
            }
        }

        return new FetchAuthTokenCache(
            $fetcher,
            $this->authCacheOptions,
            $this->authCache
        );
    }
724628
protected static function callBoundMethod($container, $callback, $default)
    {
        if (! is_array($callback)) {
            return $default instanceof Closure ? $default() : $default;
        }

        // Here we need to turn the array callable into a Class@method string we can use to
        // examine the container and see if there are any method bindings for this given
        // method. If there are, we can call this method binding callback immediately.
        $method = static::normalizeMethod($callback);

        if ($container->hasMethodBinding($method)) {
            return $container->callMethodBinding($method, $callback[0]);
        }

        return $default instanceof Closure ? $default() : $default;
    }
1202708
private function withPrimaryReadPreference(\Closure $closure)
    {
        $prevReadPref = $this->mongoCollection->getReadPreference();
        $this->mongoCollection->setReadPreference(\MongoClient::RP_PRIMARY);

        try {
            return $closure();
        } finally {
            $prevTags = ! empty($prevReadPref['tagsets']) ? $prevReadPref['tagsets'] : [];
            $this->mongoCollection->setReadPreference($prevReadPref['type'], $prevTags);
        }
    }
522096
function chain(\Closure $func, $default = null)
    {
        $i    = 0;
        $prev = $default;
        foreach ($this->getIterator() as $key => $val) {
            if ($i++ !== 0)
                $prev = $func($val, $key, $prev);
            else
                // use default value of argument of given closure
                $prev = $func($val, $key);

        }

        return $prev;
    }
1138976
public function setValidator($validator)
    {
        $this->clearCache();
        $this->validators = [];
        $this->addValidator($validator);

        return $this;
    }