From deaec7c0acf77241511bdc530ced6a05a6c9946b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 25 Nov 2021 10:21:30 +0100 Subject: [PATCH] Report validation error if a package replaces and conflicts against the same name, fixes #9845 --- src/Composer/Package/Loader/ValidatingArrayLoader.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Composer/Package/Loader/ValidatingArrayLoader.php b/src/Composer/Package/Loader/ValidatingArrayLoader.php index 9fd890385..0cb9b48c0 100644 --- a/src/Composer/Package/Loader/ValidatingArrayLoader.php +++ b/src/Composer/Package/Loader/ValidatingArrayLoader.php @@ -281,6 +281,11 @@ class ValidatingArrayLoader implements LoaderInterface $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning'; } } + + if ($linkType === 'conflict' && isset($this->config['replace']) && $keys = array_intersect_key($this->config['replace'], $this->config['conflict'])) { + $this->errors[] = $linkType.'.'.$package.' : you cannot conflict with a package that is also replaced, as replace already creates an implicit conflict rule'; + unset($this->config[$linkType][$package]); + } } } }