Flattens all cases into their respective suites.

@return array $suites a collection of suites and their cases
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);
    }
686537
protected function flattenArray(array $values, $previous = '')
    {
        $result = array();
        foreach ($values as $key => $value) {
            if ($previous) {
                $key = $previous.'['.$key.']';
            }
            if (is_array($value)) {
                $result = $result + $this->flattenArray($value, $key);
            } else {
                $result[$key] = $value;
            }
        }

        return $result;
    }
909009
public function squash() : Collection
    {
        if (count($this->stack) || !($this->array instanceof \ArrayObject)) {
            $this->array = new \ArrayObject(iterator_to_array($this));
            $this->stack = [];
            $this->iterator = $this->array->getIterator();
        }
        return $this;
    }
849669
public function allPreserveCase()
    {
        $headers = array();
        foreach ($this->all() as $name => $value) {
            $headers[isset($this->headerNames[$name]) ? $this->headerNames[$name] : $name] = $value;
        }

        return $headers;
    }
971829
public function flatten(array $array)
    {
        $return = [];
        foreach ($array as $key => $value) {
            if (in_array($key, $this->exceptions)) {
                $return[$key] = $value;
            } else {
                $return[] = $value;
            }
        }

        return $return;
    }
908524
public static function flatten(array $values)
    {
        $results = [];

        array_walk_recursive(
            $values,
            function($value) use (&$results) {
                $results[] = $value;
            }
        );

        return $results;
    }
238579
protected function getSuiteRoot(array $suites): \DOMElement
    {
        $testsuites = $this->document->createElement('testsuites');
        $this->document->appendChild($testsuites);
        if (\count($suites) === 1) {
            return $testsuites;
        }
        $rootSuite = $this->document->createElement('testsuite');
        $attrs = $this->getSuiteRootAttributes($suites);
        foreach ($attrs as $attr => $value) {
            $rootSuite->setAttribute($attr, (string) $value);
        }
        $testsuites->appendChild($rootSuite);

        return $rootSuite;
    }
652157
public function toArray($nesting = false)
    {
        $output = [];
        foreach ($this::getReflection()->getProperties() as $propertyName => $property) {

            $value = $this->{$propertyName};
            if (($value instanceof Entity\Collection || $value instanceof Entity)
                && $nesting
            ) {
                $output[$propertyName] = $value->toArray($nesting);
            } else {
                $output[$propertyName] = $value;
            }
        }

        return $output;
    }
782431
public static function flatten($arr) {
		if(!is_array($arr))
			return [$arr];
		$res = [];
		foreach($arr as $k=>$v) {
			if(is_array($v))
				$res = array_merge($res, static::flatten($v));
			else
				$res[] = $v;
		}
		return $res;
	}
614948
public function toCleanArray()
    {
        $export = $this->toArray();

        $cleanExport = array();
        foreach ($export as $key => $value) {
            if ($value) {
                $cleanExport[$key] = $value;
            }
        }

        return $cleanExport;
    }
499985
protected function extendEmptyCasesFromSuites(array $cases, TestSuite $suite)
    {
        $class = $suite->name;
        $file = $suite->file;

        /** @var TestCase $case */
        foreach ($cases as $case) {
            if (empty($case->class)) {
                $case->class = $class;
            }
            if (empty($case->file)) {
                $case->file = $file;
            }
        }
    }
1310058
protected function flattenArguments()
	{
		$args = func_get_args();
		$flat = [];

		foreach ($args as $arg) {
			if (is_array($arg)) {
				$flat = call_user_func_array(array($this, 'flattenArguments'), array_merge($flat, $arg));
				continue;
			}
			array_push($flat, $arg);
		}

		return $flat;
	}
1035809
public function collapse(): Collection
    {
        $results = [];

        foreach ($this->items as $values) {
            if ($values instanceof self) {
                $values = $values->all();
            } elseif (! is_array($values)) {
                continue;
            }

            $results = array_merge($results, $values);
        }

        return new static($results);
    }
745930
public function flatten()
	{
		$flatten = [];
		$this->flattenString('', $this->strings, $flatten);
		$this->strings = $flatten;
	}
984428
public function flatten()
    {
        return new Enumerator(
            function () {
                foreach ($this->each() as $k => $v) {
                    if (($v instanceof \Traversable) || is_array($v)) {
                        yield $k => Enumerator::from($v)->flatten();
                    } else {
                        yield $k => $v;
                    }
                }
            }
        );
    }
135950
protected function flattenConfig(array $config)
	{
		foreach ($config as $k => $v)
		{
			if (is_array($v) && count($v) === 1)
			{
				$config[$k] = end($v);
			}
		}

		return $config;
	}
1093568
public static function flattenSeparated(array $values, $sep = '.')
    {
        $result = [];
        $stack  = [
            [
                '',
                $values
            ]
        ];

        while (count($stack) > 0) {
            list($prefix, $values) = array_pop($stack);

            foreach ($values as $key => $value) {
                $newKey = $prefix . (string) $key;

                if (is_array($value)) {
                    $stack[] = [
                        $newKey . $sep,
                        $value
                    ];
                } else {
                    $result[$newKey] = $value;
                }
            }
        }

        return $result;
    }