*
* @param array $arguments An array of Reference objects
* @param bool $inMethodCall
+ * @param bool $inCollection
*
* @return array
*
* @throws RuntimeException When the config is invalid
*/
- private function processArguments(array $arguments, $inMethodCall = false)
+ private function processArguments(array $arguments, $inMethodCall = false, $inCollection = false)
{
+ $isNumeric = array_keys($arguments) === range(0, count($arguments) - 1);
+
foreach ($arguments as $k => $argument) {
if (is_array($argument)) {
- $arguments[$k] = $this->processArguments($argument, $inMethodCall);
+ $arguments[$k] = $this->processArguments($argument, $inMethodCall, true);
} elseif ($argument instanceof Reference) {
$id = (string) $argument;
if (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) {
$arguments[$k] = null;
} elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) {
+ if ($inCollection) {
+ unset($arguments[$k]);
+ continue;
+ }
if ($inMethodCall) {
throw new RuntimeException('Method shouldn\'t be called.');
}
}
}
+ // Ensure numerically indexed arguments have sequential numeric keys.
+ if ($isNumeric) {
+ $arguments = array_values($arguments);
+ }
+
return $arguments;
}
}