protected function optimizeBranchesOutput(array &$branches, $which)
	{
		$expressions = [];
		while (isset($branches[0][$which][0]))
		{
			$expr = $branches[0][$which][0];
			foreach ($branches as $branch)
			{
				if (!isset($branch[$which][0]) || $branch[$which][0] !== $expr)
				{
					break 2;
				}
			}

			$expressions[] = $expr;
			foreach ($branches as &$branch)
			{
				array_shift($branch[$which]);
			}
			unset($branch);
		}

		return $expressions;
	}
protected function optimizeBranchesOutput(array &$branches, $which)
	{
		$expressions = [];
		while (isset($branches[0][$which][0]))
		{
			$expr = $branches[0][$which][0];
			foreach ($branches as $branch)
			{
				if (!isset($branch[$which][0]) || $branch[$which][0] !== $expr)
				{
					break 2;
				}
			}

			$expressions[] = $expr;
			foreach ($branches as &$branch)
			{
				array_shift($branch[$which]);
			}
			unset($branch);
		}

		return $expressions;
	}
protected function optimizeBranchesOutput ( array & $ branches , $ which ) { $ expressions = [ ] ; while ( isset ( $ branches [ 0 ] [ $ which ] [ 0 ] ) ) { $ expr = $ branches [ 0 ] [ $ which ] [ 0 ] ; foreach ( $ branches as $ branch ) { if ( ! isset ( $ branch [ $ which ] [ 0 ] ) || $ branch [ $ which ] [ 0 ] !== $ expr ) { break 2 ; } } $ expressions [ ] = $ expr ; foreach ( $ branches as & $ branch ) { array_shift ( $ branch [ $ which ] ) ; } unset ( $ branch ) ; } return $ expressions ; }
Optimize the output of given branches

@param  array    &$branches Array of branches
@param  string    $which    Which end to optimize ("head" or "tail")
@return string[]            PHP expressions removed from the given part of the branches
Optimize the output of given branches