Merges the incoming structure definition with the existing structure.

@return  void

@note    Currently only supports XML format.
@since   1.0
@throws  \RuntimeException on error.
186292
protected function mergeStructure()
	{
		$prefix = $this->db->getPrefix();
		$tables = $this->db->getTableList();

		if ($this->from instanceof \SimpleXMLElement)
		{
			$xml = $this->from;
		}
		else
		{
			$xml = new \SimpleXMLElement($this->from);
		}

		// Get all the table definitions.
		$xmlTables = $xml->xpath('database/table_structure');

		foreach ($xmlTables as $table)
		{
			// Convert the magic prefix into the real table name.
			$tableName = (string) $table['name'];
			$tableName = preg_replace('|^#__|', $prefix, $tableName);

			if (in_array($tableName, $tables))
			{
				// The table already exists. Now check if there is any difference.
				if ($queries = $this->getAlterTableSQL($xml->database->table_structure))
				{
					// Run the queries to upgrade the data structure.
					foreach ($queries as $query)
					{
						$this->db->setQuery((string) $query);

						try
						{
							$this->db->execute();
						}
						catch (\RuntimeException $e)
						{
							$this->addLog('Fail: ' . $this->db->getQuery());
							throw $e;
						}
						$this->addLog('Pass: ' . $this->db->getQuery());
					}
				}
			}
			else
			{
				// This is a new table.
				$sql = $this->xmlToCreate($table);

				$this->db->setQuery((string) $sql);

				try
				{
					$this->db->execute();
				}
				catch (\RuntimeException $e)
				{
					$this->addLog('Fail: ' . $this->db->getQuery());
					throw $e;
				}
				$this->addLog('Pass: ' . $this->db->getQuery());
			}
		}
	}
945956
protected function populateStructure()
    {
        $treeStructure = [
            'reconcile' => [
                'arn'               => $this->arn,
                'transaction_id'    => $this->transaction_id,
                'unique_id'         => $this->unique_id
            ]
        ];

        $this->treeStructure = \Genesis\Utils\Common::createArrayObject($treeStructure);
    }
33242
protected function shallowMaterializeNodeData(): void
    {
        if ($this->isNodeDataMatchingContext()) {
            return;
        }

        $dimensions = $this->context->getTargetDimensionValues();

        $newNodeData = new NodeData($this->nodeData->getPath(), $this->context->getWorkspace(), $this->nodeData->getIdentifier(), $dimensions);
        $this->nodeDataRepository->add($newNodeData);

        $newNodeData->similarize($this->nodeData);

        $this->nodeData = $newNodeData;
        $this->nodeDataIsMatchingContext = true;
    }
1235715
public function mergeValuesBase(array $values): void
  {
    if (array_key_exists($this->name, $values))
    {
      $this->setValuesBase($values);
    }
  }
716847
public static function merge()
    {
        $array = func_get_arg(0);
        $Arr = array_slice(func_get_args(), 1);

        if (!is_array($array)) {
            throw new \Exception('Arr::merge() - all arguments must be Array.');
        }

        foreach ($Arr as $arr) {
            if (!is_array($arr)) {
                throw new \Exception('Arr::merge() - all arguments must be Array.');
            }

            foreach ($arr as $key => $value) {
                if (is_int($key)) {
                    array_key_exists($key, $array) ? array_push($array, $value) : $array[$key] = $value;
                } elseif (is_array($value) && array_key_exists($key, $array) && is_array($array[$key])) {
                    $array[$key] = self::merge($array[$key], $value);
                } else {
                    $array[$key] = $value;
                }
            }
        }

        return $array;
    }
124662
public function mergeApplicationDefinition($mergeArgs = true)
    {
        if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
            return;
        }

        $this->definition->addOptions($this->application->getDefinition()->getOptions());

        $this->applicationDefinitionMerged = true;

        if ($mergeArgs) {
            $currentArguments = $this->definition->getArguments();
            $this->definition->setArguments($this->application->getDefinition()->getArguments());
            $this->definition->addArguments($currentArguments);

            $this->applicationDefinitionMergedWithArgs = true;
        }
    }
527477
public function dump()
    {
        if (!method_exists($this->filesystem, 'dumpFile')) {
            throw new \RuntimeException('Method dumpFile() is not available on your Filesystem component version, you should upgrade it.');
        }

        $this->initDirection();
        $feed = $this->feedManager->get($this->name);

        if ($this->entity) {
            $repository = $this->em->getRepository($this->entity);
            $items = $repository->findBy([], $this->orderBy, $this->limit);
            $feed->addFromArray($items);
        } elseif ($feed->hasItems()) {
            throw new \LogicException(sprintf('An entity should be set OR you should use setItems() first'));
        }

        $dump = $feed->render($this->format);
        $filepath = $this->rootDir.$this->filename;

        $this->filesystem->dumpFile($filepath, $dump);
    }
654906
public function addUnique($x)
	{
		if (isset($this->parents[$x])) {
			throw new \RuntimeException('Element "'.$x.'" is already present in the union find.');
		}
		$this->parents[$x] = $x;
	}
420342
protected function configure()
    {
        $this->setName('phpjunitmerge')
            ->setDefinition(
                array(
                    new InputArgument(
                        'dir',
                        InputArgument::REQUIRED,
                        'Directory where all files ready to get merged are stored'
                    ),
                    new InputArgument(
                        'file',
                        InputArgument::REQUIRED,
                        'The target file in which the merged result should be written'
                    )
                )
            )
            ->addOption(
                'names',
                null,
                InputOption::VALUE_REQUIRED,
                'A comma-separated list of file names to check',
                '*.xml'
            )
            ->addOption(
                'ignore',
                null,
                InputOption::VALUE_REQUIRED,
                'A comma-separated list of file names to ignore',
                'result.xml'
            )
			->addOption(
				'no-suffix',
				null,
				InputOption::VALUE_NONE,
				'Do not add suffix for test suites with duplicate names',
				null
			);
    }
1165772
public function append()
    {
        $this->importNodes(\func_get_args(), function ($node, $imported_node) {
            $node->appendChild($imported_node);
        });

        return $this;
    }
1156582
protected function attach_nodes_to_categories() {
        foreach ($this->nodes as $node) {
            $parentcat = $node->parentcat;
            if (!isset($this->categories[$parentcat])) {
                throw new \coding_exception("Category $parentcat doesn't exist");
            } else {
                $this->categories[$parentcat]->add_node($node);
            }
        }
    }
1306724
public function initialize()
    {
        if (null !== $this->collection) {
            return;
        }

        if (empty($this->dbOptions['database'])) {
            throw new \RuntimeException('The option "database" must be set');
        }
        if (empty($this->dbOptions['collection'])) {
            throw new \RuntimeException('The option "collection" must be set');
        }

        $this->collection = $this
            ->mongo
            ->selectDB($this->dbOptions['database'])
            ->selectCollection($this->dbOptions['collection']);
    }
153937
protected function instantiateNode()
    {
        if (null === $this->values) {
            throw new \RuntimeException('You must call ->values() on enum nodes.');
        }

        return new EnumNode($this->name, $this->parent, $this->values, $this->pathSeparator);
    }
864099
public function mergeData()
    {
        if (isset($this->_data) && is_array($this->_data)) {
            // merge primitive types
            foreach ($this->_data as $member => $value) {
                if (!is_array($value)) {
                    if ($member == 'type') {
                        $this->set('type', new type($value, $this->_root));
                    } else {
                        $this->set($member, $value);
                    }
                }
            }
            // merge tags array
            if (isset($this->_data['tags']) && is_array($this->_data['tags'])) {
                $thisClass = strtolower(get_class($this));
                foreach ($this->_data['tags'] as $name => $tag) {
                    if (is_array($tag)) {
                        foreach ($this->_data['tags'][$name] as $key => $tag) {
                            if (
                                ($thisClass == 'rootdoc' && $this->_data['tags'][$name][$key]->inOverview()) ||
                                ($thisClass == 'packagedoc' && $this->_data['tags'][$name][$key]->inPackage()) ||
                                ($thisClass == 'classdoc' && $this->_data['tags'][$name][$key]->inType()) ||
                                ($thisClass == 'methoddoc' && $this->_data['tags'][$name][$key]->inMethod()) ||
                                ($thisClass == 'fielddoc' && $this->_data['tags'][$name][$key]->inField())
                            ) {
                                $this->_tags[$name][$key] =& $this->_data['tags'][$name][$key];
                                $this->_tags[$name][$key]->setParent($this);
                            }
                        }
                    } else {
                        if (
                            ($thisClass == 'rootdoc' && $this->_data['tags'][$name]->inOverview()) ||
                            ($thisClass == 'packagedoc' && $this->_data['tags'][$name]->inPackage()) ||
                            ($thisClass == 'classdoc' && $this->_data['tags'][$name]->inType()) ||
                            ($thisClass == 'methoddoc' && $this->_data['tags'][$name]->inMethod()) ||
                            ($thisClass == 'fielddoc' && $this->_data['tags'][$name]->inField())
                        ) {
                            $this->_tags[$name] =& $this->_data['tags'][$name];
                            $this->_tags[$name]->setParent($this);
                        }
                    }
                }
            }
            // merge parameter types
            if (isset($this->_parameters) && isset($this->_data['parameters'])) {
                foreach ($this->_data['parameters'] as $name => $param) {
                    if (substr($name, 0, 9) == '__unknown') {
                        $index = substr($name, 9);
                        $parameters = array_values($this->_parameters);
                        if (isset($parameters[$index])) {
                            $parameters[$index]->set('type', new type($param['type'], $this->_root));
                        }
                    } else {
                        if (!isset($this->_parameters[$name])) {
                            //phpdoctor::warning('Unknown parameter "'.$name.'" found for method "'.$this->_package.'.'.$this->_parent->name().'::'.$this->_name.'".');
                            $this->_parameters[$name] =& new fieldDoc($name, $this, $this->_root);
                            if (isset($this->_package)) $this->_parameters[$name]->set('package', $this->_package);
                        }
                        $this->_parameters[$name]->set('type', new type($param['type'], $this->_root));
                    }
                }
            }
            // merge return type
            if (isset($this->_returnType) && isset($this->_data['return'])) {
                $this->_returnType =& new type($this->_data['return'], $this->_root);
            }
            // merge exceptions
            if (isset($this->_throws) && isset($this->_data['throws'])) {
                foreach ($this->_data['throws'] as $name => $exception) {
                    $this->_throws[$name] =& $this->_data['throws'][$name];
                }
            }
        }
        // remove data array since we no longer need it
        #unset($this->_data);
    }
1001672
public function commit()
    {
        try {
            $this->storeAllTables();

            $this->snapshot = [];
        } catch (\Exception $e) {
            throw new \RuntimeException('Commit failed: ' . $e->getMessage(), 0, $e);
        }
    }
287485
public function end()
    {
        if ($this->getCounter() === 0)
        {
            throw new \RuntimeException("The section {$this->name} already closed.");
        }

        $this->appendContent(ob_get_clean());

        $this->counter--;

        /**
         * @deprecated
        */
        $this->closed = $this->isClosed();
    }
782523
function run()
    {
        $xml = simplexml_load_file($this->structureXmlFile);

        $this->getClassDefinitions($xml);

        foreach ($this->classDefinitions as $className => $classInfo) {
            $this->expandMethods($className);
            $this->expandProperties($className);
        }

        return $this->classDefinitions;
    }