Recursively deserialize an array of (property) values. Use callbacks to further deserialize more complicated
values.

@param array $values
@param array $callbacks
@return array
343086
public static function deserialize(array $values, array $callbacks = []): array
    {
        $deserializedData = [];
        foreach ($values as $property => $value) {
            if (isset($callbacks[$property])) {
                if (is_array($value) && ArrayHelper::isNumericallyIndexed($value)) {
                    $value = array_map($callbacks[$property], $value);
                } elseif ($value !== null) {
                    // if $value is null, we don't call the callable, since its type-hint may then cause a fatal error
                    $value = $callbacks[$property]($value);
                }
            }

            $deserializedData[$property] = $value;
        }

        return $deserializedData;
    }
1096988
public function reverseTransform($values)
    {
        if (!is_array($values) || count($values) === 0) {
            return new ArrayCollection();
        }

        // get multiple entities with one query
        $tags = new ArrayCollection();

        $entities = $this->em->createQueryBuilder()
            ->select('entity')
            ->from($this->className, 'entity')
            ->where('entity.'.$this->primaryKey.' IN (:ids)')
            ->setParameter('ids', $values)
            ->getQuery()
            ->getResult();

        return array_merge($entities, $tags->toArray());
    }
1067242
private static function getValues(array $values)
    {
        $bag = MutableBag::from($values);
        foreach ($bag as $k => $v) {
            /** @var Bag $v */
            if (is_array($v) && !is_callable($v)) {
                $bag[$k] = Bag::from($v)
                    ->call(function (array $a) {
                        return [Json::dump($a)];
                    })
                    ->join(' ')
                ;
            } elseif (is_string($v) || (is_object($v) && method_exists($v, '__toString'))) {
                $bag[$k] = (string) $v;
            } else {
                $bag->remove($k);
            }
        }

        return $bag->immutable();
    }
949326
protected function collectValues(array $values, array $defaults = [])
    {
        foreach ($values as $value) {
            $defaults = $this->collectValue($value, $defaults);
        }

        return $defaults;
    }
1211280
public function setValues($values=array()) {
		return $this->_addOrSetValues($values, function(HtmlTR $row,$_values){$row->setValues($_values);});
	}
1126749
protected function getBindingsMergedWithValues(array $values)
    {
        $bindings = [];

        foreach ($values as $key => $value)
        {
            $bindings[$key .'_update'] = $value;
        }

        return array_merge($this->getBindings(), $bindings);
    }
943452
private function serializeHierarchy($values) {
    if ($this->isDeserializedNode($values)) {
      // the values represent a node
      $values = $this->serializeNode($values);
    }
    else {
      if (is_array($values) || ($values instanceof \Traversable)) {
        foreach ($values as $key => $value) {
          if ($value != null && !is_scalar($value)) {
            // array/object value
            $result = $this->serializeHierarchy($value);
            if (ObjectId::isValid($key)) {
              $values = $result;
            }
            else {
              $values[$key] = $result;
            }
          }
          else {
            // string value
            $values[$key] = $value;
          }
        }
      }
    }
    return $values;
  }
71220
private function callback($value, array $callbacks)
    {
        foreach ($callbacks as $fct) {
            $parts = explode(':', $fct);
            $functionName = array_shift($parts);
            array_unshift($parts, $value);
            $value = call_user_func_array($functionName, $parts);
        }

        return $value;
    }
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;
    }
1370900
function fromAssociativeResultArray($values) {
		foreach (static::$_columns as $column_name => &$type) {
			if (array_key_exists($column_name, $values)) {
				$this->{$column_name} = $values[$column_name];
			}
		}
		if (static::$_primaryKeys && !$this->hasPrimaryKeyValues()) {
			return false;
		}
		$this->castInts();
		$this->setNew(false);
		return true;
	}
1105412
protected function iterate($values)
    {
        if (!is_object($values) && !is_array($values)) {
            throw new \InvalidArgumentException("Unable to validate provided object");
        }
        $errors = [];
        foreach ($this->ruleset as $field => $rules) {
            $value = $this->access($values, $field);
            $error = $rules->apply($value, $values);
            if ($error !== null) {
                $errors[$field] = count($error) > 1 || count(array_filter(array_keys($error), 'is_string')) > 0 ?
                    $error : current($error);
            }
        }
        return $errors;
    }
1258032
public function setValues(array $values)
    {
        foreach ($values as $name => $value) {
            $this->fields->set($name, $value);
        }

        return $this;
    }
641087
public function encode($values)
    {
        $json = json_encode($values);

        $this->handleJsonError('Failed to encode group values to JSON');

        return parent::encode($json);
    }
1214381
protected function getValues(array $values)
    {
        $array = [];

        $versionedKeys = array_merge(
            $this->model->getVersionedAttributeNames(),
            [$this->model->getLatestVersionColumn(), $this->model->getVersionColumn(), $this->model->getVersionKeyName()]
        );

        foreach ($values as $key => $value) {
            if (! $this->isVersionedKey($key, $versionedKeys)) {
                $array[$key] = $value;
            }
        }

        return $array;
    }
308147
public function pullAll(array $values)
    {
        $this->requiresCurrentField();
        $this->newObj['$pullAll'][$this->currentField] = $values;
        return $this;
    }
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;
    }
493938
protected function prepareCallbacks($callbacks)
    {
        if (is_array($callbacks)) {
            foreach ($callbacks as &$callback) {
                $callback['callback'] = $this->serializeClosure($callback['callback']);
            }
        } else {
            $callbacks = $this->serializeClosure($callbacks);
        }

        return $callbacks;
    }