mirror of
https://github.com/composer/composer
synced 2025-05-10 17:12:51 +00:00
ValidatingArrayLoader: fix link validation with missing name (#11830)
This commit is contained in:
parent
e88c7a8987
commit
9a656854ad
2 changed files with 7 additions and 1 deletions
|
@ -253,7 +253,7 @@ class ValidatingArrayLoader implements LoaderInterface
|
||||||
if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
|
if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
|
||||||
foreach ($this->config[$linkType] as $package => $constraint) {
|
foreach ($this->config[$linkType] as $package => $constraint) {
|
||||||
$package = (string) $package;
|
$package = (string) $package;
|
||||||
if (0 === strcasecmp($package, $this->config['name'])) {
|
if (isset($this->config['name']) && 0 === strcasecmp($package, $this->config['name'])) {
|
||||||
$this->errors[] = $linkType.'.'.$package.' : a package cannot set a '.$linkType.' on itself';
|
$this->errors[] = $linkType.'.'.$package.' : a package cannot set a '.$linkType.' on itself';
|
||||||
unset($this->config[$linkType][$package]);
|
unset($this->config[$linkType][$package]);
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -426,6 +426,12 @@ class ValidatingArrayLoaderTest extends TestCase
|
||||||
],
|
],
|
||||||
['replace.0 : invalid version constraint (Could not parse version constraint acme/bar: Invalid version string "acme/bar")'],
|
['replace.0 : invalid version constraint (Could not parse version constraint acme/bar: Invalid version string "acme/bar")'],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'require' => ['acme/bar' => '^1.0']
|
||||||
|
],
|
||||||
|
['name : must be present'],
|
||||||
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue