How to fix the «Object DOMDocument should be created» bug in Magento 2.2

Step 1

Find the line:
https://github.com/magento/magento2/blob/2cacd80/lib/internal/Magento/Framework/Data/Argument/Interpreter/ArrayType.php#L42-L42

Add the following code before:

/** @var int $initialOrdering */
$initialOrdering = 0;
foreach ($items as &$item) {
	/** @var array(string => string|int) $item */
	$item['initialOrdering'] = $initialOrdering++;
}

Step 2

Find the code:
https://github.com/magento/magento2/blob/2cacd80/lib/internal/Magento/Framework/Data/Argument/Interpreter/ArrayType.php#L70-L73

Add the following code before:

if (!$firstValue && !$secondValue) {
	return $firstItem['initialOrdering'] - $secondValue['initialOrdering'];
}

The erroneous core is an usual Magento 2 “friday commit”: Magento 2 team is worried about reporting “my weekly job is done” on Fridays, and commits a lot of bugs every Friday:

https://github.com/magento/magento2/commit/eb975d28

This fix also fixes the bug «Missing required argument $routerList of Magento\Framework\App\RouterList».

It has been fixed in the core:
https://github.com/magento/magento2/commit/ddb6c1c6a8796134e940f0a2b3dd1f32e7f6cdf0