Merge two arrays by using blueprints.

@param  array $data1
@param  array $data2
@param  string $name         Optional
@param  string $separator    Optional
@return array
485691
public function mergeData(array $data1, array $data2, $name = null, $separator = '.')
    {
        $this->initInternals();

        return $this->blueprintSchema->mergeData($data1, $data2, $name, $separator);
    }
1350446
public static function camelify( string $name, $separator = '.' ): string {

    // preprocess the separator and the name inputs
    $separator = is_array( $separator ) ? $separator : [ $separator ];
    foreach( $separator as &$tmp ) {

      $tmp  = $tmp{0};
      $name = preg_replace( '/\\' . preg_quote( $tmp, '/' ) . '+/i', $tmp, trim( $name, $tmp ) );
    }

    // create the new name
    $return = '';
    for( $i = 0, $length = mb_strlen( $name ); $i < $length; ++$i ) {
      if( in_array( $name{$i}, $separator ) ) $return .= mb_strtoupper( $name{++$i} );
      else $return .= $name{$i};
    }

    return $return;
  }
1206236
protected static function arrayMergeRecursive($array1, $array2)
	{
		if ( !is_array($array1) || !is_array($array2) ) {
			return $array2;
		}

		foreach ( $array2 as $array2_key => $array2_value ) {
			if ( isset($array1[$array2_key]) ) {
				$array1[$array2_key] = self::arrayMergeRecursive($array1[$array2_key], $array2_value);
			}
			else {
				$array1[$array2_key] = $array2_value;
			}
		}

		return $array1;
	}
814975
public static function combine(array $parts, $separator = null)
    {
        $separator = $separator ?: self::getDirectorySeparator();

        $unifiedParts = array_values($parts);
        array_walk($unifiedParts, function (&$part, $key) use ($separator) {
            $part = PathHelper::unify($part);
            $part = $key === 0 ? $part : ltrim($part, $separator);
        });

        return implode($separator, $unifiedParts);
    }
823438
public static function createFromArray($name, array $data = [])
    {
        $class = new static($name);

        $class->setType($data['type']);
        if (isset($data['usage'])) {
            \assert($class instanceof TraitDefinition);
            $class->setUsage($data['usage']);
        }
        if (isset($data['required'])) {
            $class->setRequired($data['required']);
        }
        if (isset($data['enum'])) {
            $class->setEnum($data['enum']);
        }
        if (\substr($name, -1) === '?') {
            $class->setRequired(false);
            $class->setName(\substr($name, 0, -1));
        }
        $class->setDefinition($data);

        return $class;
    }
914061
public static function createFromArray($name, array $data = [])
    {
        $type = parent::createFromArray($name, $data);
        \assert($type instanceof self);
        $type->setPossibleTypes(\explode('|', $type->getType()));
        $type->setType('union');

        if (isset($data['properties'])) {
            $type->setProperties($data['properties']);
        }

        if (isset($data['additionalProperties'])) {
            $type->setAdditionalProperties($data['additionalProperties']);
        }

        return $type;
    }
276301
public function splitTagNames($names, $separator=',')
    {
        $tags = explode($separator, $names);
        $tags = array_map('trim', $tags);
        $tags = array_filter($tags, function ($value) { return !empty($value); });

        return array_values($tags);
    }
72499
private static function arrayRecursiveMerge($array1, $array2) {

		if(false === is_array($array1) || false === is_array($array2)) { 
			return $array2; 
		}

		foreach($array2 as $key => $value) {
			$array1[$key] = static :: arrayRecursiveMerge(@$array1[$key], $value);
		}

		return $array1;
	}
87319
public static function createFromArray($name, array $data = [])
    {
        $type = parent::createFromArray($name, $data);
        \assert($type instanceof self);

        foreach ($data as $key => $value) {
            switch ($key) {
                case 'minimum':
                    $type->setMinimum($value);

                    break;
                case 'maximum':
                    $type->setMaximum($value);

                    break;
                case 'format':
                    $type->setFormat($value);

                    break;
                case 'multipleOf':
                    $type->setMultipleOf($value);

                    break;
            }
        }

        return $type;
    }
1232643
public function extract($name, $separator = '.')
    {
        $filter = $this->filter instanceof NullFilter ? null : $this->filter;

        return new static($this->get($name, [], 'raw', $separator), $filter);
    }
188488
private function flattenArray(array $arrayToFlatten, $separator = '.', $flattenedKey = '')
    {
        $flattenedArray = [];
        foreach ($arrayToFlatten as $key => $value) {
            $tmpFlattendKey = (!empty($flattenedKey) ? $flattenedKey . $separator : '') . $key;
            // only append next value if is array and is an associative array
            if (is_array($value) && array_keys($value) !== range(0, count($value) - 1)) {
                $flattenedArray = array_merge(
                    $flattenedArray,
                    $this->flattenArray(
                        $value,
                        $separator,
                        $tmpFlattendKey
                    )
                );
            } else {
                $flattenedArray[$tmpFlattendKey] = $value;
            }
        }
        return $flattenedArray;
    }
1115836
public function joinDefaults($name, $value, $separator = null)
    {
        if (\is_object($value)) {
            $value = (array) $value;
        }

        $old = $this->get($name, null, $separator);
        if ($old !== null) {
            $value = $this->getBlueprint()->mergeData($value, $old, $name, $separator);
        }

        $this->setNestedProperty($name, $value, $separator);

        return $this;
    }
294500
public static function removeByPath(&$data, $path, $separator = '.')
    {
        $nodes = array_values(array_filter(explode($separator, $path), 'strlen'));

        if (empty($nodes)) {
            return false;
        }

        $previous = null;
        $dataTmp = &$data;

        foreach ($nodes as $node) {
            if (is_object($dataTmp)) {
                if (empty($dataTmp->$node)) {
                    return false;
                }

                $previous = &$dataTmp;
                $dataTmp = &$dataTmp->$node;
            } elseif (is_array($dataTmp)) {
                if (empty($dataTmp[$node])) {
                    return false;
                }

                $previous = &$dataTmp;
                $dataTmp = &$dataTmp[$node];
            } else {
                return false;
            }
        }

        // Now, path go to the end, means we get latest node, set value to this node.
        if (is_object($previous)) {
            unset($previous->$node);
        } elseif (is_array($previous)) {
            unset($previous[$node]);
        }

        return true;
    }
967660
public static function createFromArray($name, array $data = [])
    {
        $type = parent::createFromArray($name, $data);
        \assert($type instanceof self);
        $pos = \strpos($type->getType(), '[]');
        if ($pos !== false) {
            $type->setItems(\substr($type->getType(), 0, $pos));
        }
        $type->setType('array');

        foreach ($data as $key => $value) {
            switch ($key) {
                case 'uniqueItems':
                    $type->setUniqueItems($value);

                    break;
                case 'items':
                    if (\is_array($value) && isset($value['type'])) {
                        $type->setItems($value['type']);

                        break;
                    }
                    $type->setItems($value);

                    break;
                case 'minItems':
                    $type->setMinItems($value);

                    break;
                case 'maxItems':
                    $type->setMaxItems($value);

                    break;
            }
        }

        return $type;
    }
1362103
private function updateAttribute($name, $value, $separator)
    {
        array_set($this->attribute, $name, implode($separator, $value));

        return $this;
    }
1147534
public static function createFromArray($name, array $data = [])
    {
        $type = parent::createFromArray($name, $data);
        \assert($type instanceof self);

        foreach ($data as $key => $value) {
            switch ($key) {
                case 'pattern':
                    $type->setPattern($value);

                    break;
                case 'minLength':
                    $type->setMinLength($value);

                    break;
                case 'maxLength':
                    $type->setMaxLength($value);

                    break;
            }
        }

        return $type;
    }
641526
public function prepend($path, $data, $separator = PHP_EOL)
    {
        if ($this->exists($path)) {
            return $this->put($path, $data.$separator.$this->get($path));
        }

        return $this->put($path, $data);
    }