Merge pull request #5343 from localheinz/fix/unstable
Fix: Do not suggest to avoid exact version constraints for unstable packagepull/5360/head
commit
32c3429c30
|
@ -151,6 +151,7 @@ class ValidatingArrayLoader implements LoaderInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$unboundConstraint = new Constraint('=', $this->versionParser->normalize('dev-master'));
|
$unboundConstraint = new Constraint('=', $this->versionParser->normalize('dev-master'));
|
||||||
|
$stableConstraint = new Constraint('=', '1.0.0');
|
||||||
|
|
||||||
foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
|
foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
|
||||||
if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
|
if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
|
||||||
|
@ -183,6 +184,7 @@ class ValidatingArrayLoader implements LoaderInterface
|
||||||
($this->flags & self::CHECK_STRICT_CONSTRAINTS)
|
($this->flags & self::CHECK_STRICT_CONSTRAINTS)
|
||||||
&& 'require' === $linkType
|
&& 'require' === $linkType
|
||||||
&& substr($linkConstraint, 0, 1) === '='
|
&& substr($linkConstraint, 0, 1) === '='
|
||||||
|
&& $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
|
||||||
) {
|
) {
|
||||||
$this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
|
$this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,6 +326,18 @@ class ValidatingArrayLoaderTest extends \PHPUnit_Framework_TestCase
|
||||||
),
|
),
|
||||||
false,
|
false,
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'name' => 'foo/bar',
|
||||||
|
'require' => array(
|
||||||
|
'bar/unstable' => '0.3.0',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
// using an exact version constraint for an unstable version should not trigger a warning
|
||||||
|
),
|
||||||
|
false,
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
array(
|
array(
|
||||||
'name' => 'foo/bar',
|
'name' => 'foo/bar',
|
||||||
|
|
Loading…
Reference in New Issue