Build a new array using a callback.

@param array|Traversable $values
@param Closure           $callback

@return array
769158
public static function build($values, Closure $callback)
    {
        $results = [];

        if (!static::isArray($values)) {
            // This is not an array!
            return $results;
        }

        foreach ($values as $key => $value) {
            list($innerKey, $innerValue) = $callback($key, $value);

            $results[$innerKey] = $innerValue;
        }

        return $results;
    }
446148
public function map(callable $callback): ArrayCollection
    {
        $items = [];

        foreach ($this->items as $key => $value) {
            $items[$key] = $callback($value, $key);
        }

        return new static($items);
    }
581849
public function findCallback(Closure $callback, $columns = ['*'])
    {
        /** @var EloquentBuilder $result */
        $result = $callback( $this->query() );

        $this->checkValidCustomCallback($result);

        return $result->first($columns);
    }
586783
public function attachment(Closure $callback)
    {
        $this->attachments[] = $attachment = new Attachment;

        $callback($attachment);

        return $this;
    }
525147
public function map($callback)
    {
        $values = $this->_map($callback);
        $this->setValues($values);
        return new Collection($values);
    }
291568
public static function map($collection, $callback)
    {
        self::assert_callable($callback);

        $result = [];

        foreach ($collection as $key => $value) {
            $result[$key] = $callback($value, $key, $collection);
        }

        return $result;
    }
1318825
public function filter(\Closure $callback)
    {
        $collection = new static();

        foreach ($this as $element) {
            if ($callback($element)) {
                $collection->attach($element);
            }
        }

        return $collection;
    }
644306
public function reject(Closure $callback)
    {
        $hash = $this->create();

        foreach ($this as $key => $value) {
            if ($callback($value, $key) == false) {
                $hash[$key] = $value;
            }
        }

        return $hash;
    }
398813
private function prepareValues($values, callable $valueCallable = null)
    {
        if (is_array($values)) {
            foreach ($values as &$value) {
                if ($valueCallable) {
                    $value = call_user_func_array($valueCallable, [(string) $value]);
                }

                $value = (string) $value;
            }
            unset($value);

            $values = array_values($values);
        } else {
            if ($valueCallable) {
                $values = call_user_func_array($valueCallable, [(string) $values]);
            }

            $values = (string) $values;
        }

        return $values;
    }
400456
public function map(\Closure $callback)
    {
        $result = [];
        foreach ($this->value as $entity) {
            $result[] = $callback($entity);
        }

        return $result;
    }
1151273
public static function create(Closure $callback = null)
    {
        if (self::$instance === null) {
            self::$instance = new self();
        }

        if ($callback instanceof Closure) {
            return $callback(self::$instance);
        }

        return self::$instance;
    }
165425
public static function each(array $set, Closure $callback, $recursive = true) {
        foreach ($set as $key => $value) {
            if (is_array($value) && $recursive) {
                $set[$key] = static::each($value, $callback, $recursive);
            } else {
                $set[$key] = $callback($value, $key);
            }
        }

        return $set;
    }
893213
public static final function make(array $Keys, callable $Callback = null): array {
		return Arr::combine($Keys, is_callable($Callback) ? Arr::each($Keys, function () use ($Callback){
			return call_user_func($Callback, func_get_arg(1)); }) : []);
	}
1115302
public static function make(\Closure $callback = null)
    {
        self::$instance = new static();

        if ($callback instanceof \Closure) {
            return $callback(self::$instance);
        }

        return self::$instance;
    }
1256269
public function generatedValue(callable $callback = null)
    {
        $generatedValue = new GeneratedValue($this->fieldBuilder, $this->classMetadata);

        if ($callback) {
            $callback($generatedValue);
        }

        $generatedValue->build();

        return $this;
    }
904176
public static function make(\Closure $callback = null)
    {
        if (is_null(static::$instance)) {
            static::$instance = new static();
        }

        if ($callback instanceof \Closure) {
            return $callback(static::$instance);
        }

        return static::$instance;
    }
464696
protected function prepareCallbacks(callable $callback/*, ... */) {
		list($init, $done, $then) = $this->getCallbacks();
		
		$context = $init();
		foreach (func_get_args() as $cb) {
			$then($context, $cb);
		}
		
		return array($context, function($result) use ($context, $done) {
			$done($context, $result);
		});
	}