Returns a new map using the results of applying a callback to each value.

The keys will be equal in both maps.

@param callable $callback Accepts two arguments: key and value, should
return what the updated value will be.

@return Map
177261
public function map(callable $callback): Map
    {
        $apply = function($pair) use ($callback) {
            return $callback($pair->key, $pair->value);
        };

        return new self(array_map($apply, $this->pairs));
    }
379748
public function addCallback(string $key, callable $callback): self
    {
        if (!isset($this->callbacks[$key])) {
            $this->callbacks[$key] = $callback;
        } else {
            throw new \Exception("Callback with key ($key) already exists");
        }

        return $this;
    }
1290622
public function each(callable $callback)
    {
        $array = $this->getArrayCopy();
        foreach ($array as $key => $value) {
            $callback($value, $key, $array);
        }
    }
1153479
public function map(callable $callback): Collection
    {
        $keys = array_keys($this->items);
        $items = array_map($callback, $this->items, $keys);

        return new static(array_combine($keys, $items));
    }
1144985
protected function getRequiredType(callable $callback)
	{
		$ref = new \ReflectionFunction($callback);
		
		if($ref->getNumberOfParameters() > 0)
		{
			$params = $ref->getParameters();
			
			if(isset($params[0]) &&  NULL !== ($type = $params[0]->getClass()))
			{
				return $type;
			}
		}
	}
921461
public function mapColumn($field, callable $callback)
    {
        return $this->map(
            function (Data $data) use ($field, $callback) {
                $data->$field = $callback($data->$field);

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

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

        $generatedValue->build();

        return $this;
    }
758323
public function apply(callable $callback)
    {
        foreach ($this->pairs as &$pair) {
            $pair->value = $callback($pair->key, $pair->value);
        }
    }
1370368
public function map($callback) : Vector
    {
        $values = $this->_map($callback);
        $this->setValues($values);
        return $this;
    }
149438
public function select ($callback)
	{
		if(!is_callable($callback)) {
			throw new \InvalidArgumentException('Invalid (not callable) callback given');
		}

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

        return $result;
    }
25630
public function group(callable $callback) {
		$array = array();
		foreach ($this->getIterator() as $index => $item) {
			$group = $callback($item);
			$array[$group][] = $item;
		}
		return new static($array);
	}
652108
public function find(callable $callback): MapInterface
    {
        foreach ($this->data as $item) {
            $result = $callback($item);
            Assert::boolean($result, \sprintf('Callback should return a boolean, but %s was returned', \gettype($result)));

            if ($result) {
                return $item;
            }
        }

        throw new ItemNotFoundException('No item found.');
    }
276276
public function map(Closure $callback)
    {
        $hash = $this->create();

        $this->each(function ($value, $key) use ($callback, $hash) {
            $hash[] = $callback($value, $key);
        });

        return $hash;
    }
1066566
public function map($callback) : ArrayList
    {
        $values = $this->_map($callback);
        $this->setValues($values);
        return $this;
    }
744976
public function map(\Closure $callback) : Collection
    {
        $keys = array_keys($this->data);
        $values = array_map($callback, $this->data, $keys);

        return static::create(array_combine($keys, $values));
    }
463483
public function find(callable $callback) {
    $matches = [];
    foreach ($this->nodes as $node) {
      if ($node instanceof ParentNode) {
        $matches = array_merge($matches, $node->find($callback)->nodes);
      }
    }
    return new NodeCollection($matches);
  }