@param callable $func

@return static
335596
public function filter($func)
    {
        $index = 0;
        $nodes = [];
        foreach ($this->_nodes as $node) {
            $selector = new Selector($this->_document, $node);
            if ($func($selector, $index++) !== false) {
                $nodes[] = $node;
            }
        }

        return new SelectorList($this, $nodes);
    }
263186
public function bind(callable $function) : Monadic
    {
        $concat = compose(
            function (array $list) use ($function) {
                return fold(
                    function ($acc, $item) use ($function) {
                        $acc[] = $function($item)->extract();

                        return $acc;
                    },
                    $list,
                    []
                );
            },
            partialLeft('array_merge', $this->collection)
        );

        return self::of(flatten($concat($this->collection)));
    }
875505
public function transactional(callable $func)
    {
        if (!\is_callable($func)) {
            throw new \InvalidArgumentException('Expected argument of type "callable", got "' . \gettype($func) . '"');
        }

        $this->connect();
        $this->pdo->beginTransaction();

        try {
            $return = $func($this);
            $this->pdo->commit();

            return $return ?: true;
        } catch (\Throwable $e) {
            $this->pdo->rollBack();
            throw $e;
        }
    }
1037776
public function setApplyFilterFunction(callable $function)
    {
        $validator = $this->getCallableValidatorApplyFilters();
        $validator->setCallableFunction($function);

        if ($validator->isValid() === false) {
            throw $validator->getException();
        }

        $this->applyFilterFunction = $function;

        return $this;
    }
923511
public function unique(callable $func = null)
    {
        return new Enumerator(
            function () use ($func) {
                $exists = [];
                foreach ($this->each() as $k => $v) {
                    $comp = $func ? $func($v) : $v;
                    if (!in_array($comp, $exists, true)) {
                        $exists[] = $comp;
                        yield $k => $v;
                    }
                }
            }
        );
    }
139166
public static function add(callable $func) {
		self::$_lPool[] = $func;
		if (!self::$_bHook) {
			self::$_bHook = TRUE;
			Page::doDelay();
		}
	}
44978
public function bind(callable $function)
    {
        // Theoretical here should be call like this:
        //  call_user_func($function, $this->run())
        // But this do not make things lazy, to cheat little bit
        // IO monad is returned and inside of it is little switch
        return static::of(function () use ($function) {
            $m = $function($this->run());

            return $m instanceof IO
                ? $m->run()
                : $m;
        });
    }
410786
function then(/*callable*/ $callable = null, /*callable*/ $failure = null)
    {
        if ($failure !== null)
            $this->onFailure($failure);

        if ($callable === null)
            return $this;
        
        
        if (! is_callable($callable) )
            throw new \Exception(sprintf(
                'The argument given is not callable; given: (%s).'
                , \Poirot\Std\flatten($callable)
            ));


        try {
            $result = call_user_func($callable, $this->collector(), $this);
        } catch(\Exception $e) {
            if ($this->failure)
                return call_user_func($this->failure, $e, $this);

            throw $e;
        }
        
        $this->then = $callable;
        return $result;
    }
112883
public function addFunc(FunctionEntity $func)
    {
        $this->fullClassName = $func->getClass();

        // Skip the method if it's an @internal one.
        $methodFullDoc = (new ReflectionMethod($this->fullClassName, $func->getName()))->getDocComment();
        foreach (explode(PHP_EOL, $methodFullDoc) as $line) {
            if (strpos($line, ' @internal ') !== false) {
                return '';
            }
        }

        $str = PHP_EOL . '<h3>' . $func->getName() . '</h3>' . "\n\n<hr>\n\n";

        $str .= $this->parser->text($func->getDescription());

        if (!$func->getExample()) {
            throw new RuntimeException("Method {$func->getClass()}::{$func->getName()} is missing an example.");
        }

        $rawExample = $func->getExample();
        $example = $this->parser->text($rawExample);
        $str .= PHP_EOL . $example;

        if ($func->hasParams()) {
            $str .= PHP_EOL . '<h4>Parameters</h4>' . PHP_EOL . '<ul>';
            $params = [];
            foreach ($func->getParams() as $param) {
                $paramStr = sprintf('<li><code>%s</code> <strong>%s</strong>', $param->getType(), $param->getName());

                $description = $param->getDescription();

                if (!empty($description)) {
                    $paramStr .= ' - ' . $this->parser->line($param->getDescription());
                }

                $params[] = $paramStr . '</li>';
            }
            $str .= PHP_EOL . implode(PHP_EOL, $params);
            $str .= '</ul>';
        }


        $this->output .= PHP_EOL . $str . PHP_EOL  . '  ';
        $this->index[] = $func->getName();
        return $str;
    }
1344937
public function setFunc($func)
    {
        if ($func === null) {
            $this->func = $func;
            return $this;
        }

        if (!is_string($func)) {
            throw new InvalidArgumentException(
                'Function name should be a string.'
            );
        }

        $func = strtoupper($func);
        if (!in_array($func, $this->validFunc())) {
            throw new InvalidArgumentException(sprintf(
                'Function "%s" not allowed in this context.',
                $func
            ));
        }

        $this->func = $func;
        return $this;
    }
1156270
public function groupBy(callable $func)
    {
        $result = [];
        foreach ($this->each() as $k => $v) {
            $this->_groupBy($result, $k, $v, $func);
        }
        return $result;
    }
401554
public function map(Closure $func) : Collection
    {
        return $this->createFrom(array_map($func, $this->elements));
    }
1064567
public static function fromCallable($callable)
    {
        if (!is_callable($callable))
        {
            throw new \InvalidArgumentException('You must provide a vaild PHP callable.');
        }
        elseif (is_string($callable) && strpos($callable, '::') > 0)
        {
            $callable = explode('::', $callable);
        }

        if (is_array($callable))
        {
            list($class, $method) = $callable;
            $reflection = new \ReflectionMethod($class, $method);
        }
        else
        {
            $reflection = new \ReflectionFunction($callable);
        }

        return new static($reflection);
    }
1312782
public static function createFromCallable(callable $callback): \ReflectionFunctionAbstract
    {
        if (\is_array($callback)) {
            return new \ReflectionMethod($callback[0], $callback[1]);
        }

        if (\is_object($callback)) {
            return new \ReflectionMethod($callback, '__invoke');
        }

        return new \eflectionFunction($callback);
    }
1214882
protected function lazyConnect($func)
    {
        // do not reconnect
        if ($this->link) {
            return;
        }

        // connect only for functions that need a link
        if (! isset($this->link_arg[$func])) {
            return;
        }

        // connect and retain the identifier
        $this->link = mysql_connect(
            $this->server,
            $this->username,
            $this->password,
            $this->new_link,
            $this->client_flags
        );

        // throw exception on error
        if (! $this->link) {
            throw new RuntimeException(
                mysql_error(),
                mysql_errno()
            );
        }
    }
1243892
public function filter(?callable $callable = null)
	{
		if($callable === null)
		{
			return new static(array_filter($this->items));
		}

		return new static(array_filter($this->items, $callable, ARRAY_FILTER_USE_BOTH));
	}
953154
public static function functionAvailable($func)
    {
        $disabled = explode(',', ini_get('disable_functions'));

        return function_exists($func) && !in_array($func, $disabled);
    }