Fold an array of testcase nodes into a suite array.

@param array $nodeArray an array of testcase nodes
@param array $testCases an array reference. Individual testcases will be placed here.

@return mixed
187792
protected function caseNodesToSuiteProperties(array $nodeArray, array &$testCases = [])
    {
        $cb = [TestCase::class, 'caseFromNode'];

        return array_reduce($nodeArray, function ($result, $c) use (&$testCases, $cb) {
            $testCases[] = \call_user_func_array($cb, [$c]);
            $result['name'] = (string) $c['class'];
            $result['file'] = (string) $c['file'];
            ++$result['tests'];
            $result['assertions'] += (int) $c['assertions'];
            $result['failures'] += \count($c->xpath('failure'));
            $result['errors'] += \count($c->xpath('error'));
            $result['skipped'] += \count($c->xpath('skipped'));
            $result['time'] += (float) $c['time'];

            return $result;
        }, static::$defaultSuite);
    }
1362656
protected function mergeMethods($nodeData)/*# : array */
    {
        // no merge
        if (empty($nodeData) || isset($nodeData[0])) {
            return (array) $nodeData;
        }

        // in sections
        $result = [];
        foreach ($nodeData as $data) {
            $result = array_merge($result, $data);
        }
        return $result;
    }
776601
function nodeListToArray (nodes) {
    if ($.env.name !== 'IE' || $.env.version > 9) {
      return prototypeSlice.call(nodes);
    }

    // IE 9 and below call use Array.prototype.slice.call against
    // a NodeList, hence the following
    var array = [];

    for (var i=0, num=nodes.length; i<num; ++i) {
      array.push(nodes[i]);
    }

    return array;
  }
27126
protected function parseDocThrows( $matches )
	{
		$throws	= new ADT_PHP_Throws( trim( $matches[1] ) );
		if( isset( $matches[2] ) )
			$throws->setReason( trim( $matches[2] ) );
		return $throws;
	}
769212
public function processAssertions(ArrayCollection $assertions) : ArrayCollection
    {
        $processed = new ArrayCollection();
        foreach ($assertions->getIterator() as $assertion) {
            $processed->add($this->process($assertion));
        }

        return $processed;
    }
760179
public function toArray(\DOMElement $dom = null, array &$array = null, $arregloNodos = false)
    {
        // determinar valores de parámetros
        if (!$dom)
            $dom = $this->documentElement;
        if (!$dom)
            return false;
        if ($array===null)
            $array = [$dom->tagName => null];
        // agregar atributos del nodo
        if ($dom->hasAttributes()) {
            $array[$dom->tagName]['@attributes'] = [];
            foreach ($dom->attributes as $attribute) {
                $array[$dom->tagName]['@attributes'][$attribute->name] = $attribute->value;
            }
        }
        // agregar nodos hijos
        if ($dom->hasChildNodes()) {
            foreach($dom->childNodes as $child) {
                if ($child instanceof \DOMText) {
                    $textContent = trim($child->textContent);
                    if ($textContent!="") {
                        if ($dom->childNodes->length==1 and empty($array[$dom->tagName])) {
                            $array[$dom->tagName] = $textContent;
                        } else
                            $array[$dom->tagName]['@value'] = $textContent;
                    }
                }
                else if ($child instanceof \DOMElement) {
                    $nodos_gemelos = $this->countTwins($dom, $child->tagName);
                    if ($nodos_gemelos==1) {
                        if ($arregloNodos)
                            $this->toArray($child, $array);
                        else
                            $this->toArray($child, $array[$dom->tagName]);
                    }
                    // crear arreglo con nodos hijos que tienen el mismo nombre de tag
                    else {
                        if (!isset($array[$dom->tagName][$child->tagName]))
                            $array[$dom->tagName][$child->tagName] = [];
                        $siguiente = count($array[$dom->tagName][$child->tagName]);
                        $array[$dom->tagName][$child->tagName][$siguiente] = [];
                        $this->toArray($child, $array[$dom->tagName][$child->tagName][$siguiente], true);
                    }
                }
            }
        }
        // entregar arreglo
        return $array;
    }
121757
private function assembleReplaceCallback(array $matches)
    {
        if (!isset($this->assembleParams[$matches[1]])) {
            throw new RuntimeException($this->translate(
                'Assemble param "{name}" does not exist.',
                ['name' => $matches[1]]
            ));
        }

        return $this->assembleParams[$matches[1]];
    }
801129
private function isChildElementHasStrictKeys(CustomArrayObject $nodeSchema, $nodeData)
    {
        $returnValue = false;

        if (!empty($nodeData) && is_array($nodeData)) {
            $schemaKeys = $nodeSchema->getArrayKeys();
            $dataKeys = count(array_filter(array_keys($nodeData), 'is_string')) ? array_keys($nodeData) : [];
            $returnValue = (bool)array_diff($dataKeys, $schemaKeys);
        }

        return $returnValue;
    }
1332743
public static function caseConvertArrayKeysRecursively(
        array $array,
        string $method = self::PASCALCASE,
        string $separator = '_'
    ): array {
        $return = [];
        foreach ($array as $key => $value) {
            if (!preg_match('/^\d+$/', $key)) {
                $key = self::$method(preg_replace('/\-/', '_', $key), true, $separator);
            }
            if (is_array($value)) {
                $value = self::caseConvertArrayKeysRecursively($value, $method);
            }
            $return[$key] = $value;
        }
        return $return;
    }
217227
public function removeNode( $nodePath )
	{
		$pathNodes	= explode( "/", $nodePath );
		$nodeName	= array_pop( $pathNodes );
		$nodePath	= implode( "/", $pathNodes );
		$nodeNumber	= 0;
		$branch		= $this->getNode( $nodePath );
		if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $nodeName, $matches ) )
		{
			$nodeName	= $matches[1][0];
			$nodeNumber	= $matches[2][0];
		}
		$nodes		=& $branch->getChildren();
		$index		= -1;
		for( $i=0; $i<count( $nodes ); $i++ )
		{
			if( !$nodeName || $nodes[$i]->getNodeName() == $nodeName )
			{
				$index++;
				if( $index != $nodeNumber ) 
					continue;
				unset( $nodes[$i] );
				return (bool) $this->write();
			}
		}
		throw new InvalidArgumentException( 'Node not found.' );
	}
684137
private function recursiveCallChild(\DOMNodeList $nodeList, callable $fct)
    {
        /**
         * @var \DOMNode $domNode
         */
        foreach ($nodeList as $domNode) {
            $fct(new GlHtmlNode($domNode));
            if ($domNode->hasChildNodes()) {
                $this->recursiveCallChild($domNode->childNodes, $fct);
            }
        }
    }
363703
protected function _toArray(DOMNodeList $nodes) {
		$array = array();
		foreach ($nodes as $node) {
			if ($node->nodeType != XML_ELEMENT_NODE) {
				continue;
			}
			if ($node->hasAttributes()) { // deep
				if ($node->tagName == 'error') {
					$array = array(
						'id' => $node->getAttribute('id'),
						'code' => $node->getAttribute('code'),
						'auxCode' => $node->getAttribute('auxCode'),
						'message' => $node->nodeValue
					);
				} else {
					// in the case of custom charges, use the id for the key
					if ($node->hasAttribute('code') && $node->getAttribute('code')) {
						$key = $node->getAttribute('code');

						$tmpArr = array();

						if ($node->hasAttribute('id')) {
							$tmpArr = array(
								'id' => $node->getAttribute('id')
							);
						}
						$tmpArr = $tmpArr + array('code'=>$key);

						// charges need to be a nested array since there can be multiple charges with the same charge code
						if ($node->tagName == 'charge') {
							$array[$key][] = $tmpArr;
						} else {
							$array[$key] = $tmpArr;
						}

						unset($tmpArr);

					} else {
						$key = $node->getAttribute('id');
						$array[$key] = array('id' => $node->getAttribute('id'));
					}
					$array[$key] = $array[$key] + $this->_toArray($node->childNodes);
				}
			} else {
				if ($node->tagName == 'errors') {
					$array[$node->tagName][] = $this->_toArray($node->childNodes);
				} else if ($node->childNodes->length > 1) { // sub array
					$array[$node->tagName] = $this->_toArray($node->childNodes);
				} else {
					$array[$node->tagName] = $node->nodeValue;
				}
			}
		}
		return $array;
	}
1042411
public static function fromParts( $context, $nodeTest, $matchSelf, $iter )
	{
		$result = new AncestorNodeIterator();
		$result->fromAxisNodeIteratorParts( $context, $nodeTest, $matchSelf, $iter );
		return $result;
	}
172253
public function flattenCases(): array
    {
        $dict = [];
        foreach ($this->getCases() as $case) {
            if (!isset($dict[$case->file])) {
                $dict[$case->file] = new TestSuite($case->class, 0, 0, 0, 0, 0, 0);
            }
            $dict[$case->file]->cases[] = $case;
            ++$dict[$case->file]->tests;
            $dict[$case->file]->assertions += $case->assertions;
            $dict[$case->file]->failures += \count($case->failures);
            $dict[$case->file]->errors += \count($case->errors);
            $dict[$case->file]->skipped += \count($case->skipped);
            $dict[$case->file]->time += $case->time;
            $dict[$case->file]->file = $case->file;
        }

        return array_values($dict);
    }
191017
protected function make(array $classes)
    {
        foreach ($classes as $index => $class) {
            try {
                $classes[$index] = $this->container->make($class);
            } catch (Throwable $e) {
                unset($classes[$index]);
                $this->report($e instanceof Exception ? $e : new FatalThrowableError($e));
            }
        }

        return array_values($classes);
    }
1020348
protected function addSuite($properties, array $testCases)
    {
        $suite = TestSuite::suiteFromArray($properties);
        $suite->cases = $testCases;
        $this->suites[0]->suites[] = $suite;
    }
130146
protected function appendSuite(\DOMElement $root, TestSuite $suite): \DOMElement
    {
        $suiteNode = $this->document->createElement('testsuite');
        $vars = get_object_vars($suite);
        foreach ($vars as $name => $value) {
            if (preg_match(static::$suiteAttrs, $name)) {
                $suiteNode->setAttribute($name, (string) $value);
            }
        }
        $root->appendChild($suiteNode);

        return $suiteNode;
    }