Skip to content

Wrong assumption on array merge #5169

Description

@dereuromark

Bug report

Code snippet that reproduces the problem

https://phpstan.org/r/86239cd8-0802-4070-8bdf-b773187103ee

	/**
	 * @param array $configs
	 *
	 * @return array
	 */	
	protected function merge(array $configs): array {
		$result = [];
		foreach ($configs as $config) {
			$result += $config;

			foreach ($config as $name => $dto) {
				$result[$name] += $dto;
			}
		}

		return $result;
	}

Expected output

no issue as long as we do not document this any further, just as before.
This didn't error a few patches before. So this looks like a too strict regression of sorts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions