diff --git a/src/Composer/Package/Dumper/ArrayDumper.php b/src/Composer/Package/Dumper/ArrayDumper.php index 6593143d5..b1e20dbf5 100644 --- a/src/Composer/Package/Dumper/ArrayDumper.php +++ b/src/Composer/Package/Dumper/ArrayDumper.php @@ -48,7 +48,9 @@ class ArrayDumper if ($package->getSourceType()) { $data['source']['type'] = $package->getSourceType(); $data['source']['url'] = $package->getSourceUrl(); - $data['source']['reference'] = $package->getSourceReference(); + if (null !== ($value = $package->getSourceReference())) { + $data['source']['reference'] = $value; + } if ($mirrors = $package->getSourceMirrors()) { $data['source']['mirrors'] = $mirrors; } @@ -57,8 +59,12 @@ class ArrayDumper if ($package->getDistType()) { $data['dist']['type'] = $package->getDistType(); $data['dist']['url'] = $package->getDistUrl(); - $data['dist']['reference'] = $package->getDistReference(); - $data['dist']['shasum'] = $package->getDistSha1Checksum(); + if (null !== ($value = $package->getDistReference())) { + $data['dist']['reference'] = $value; + } + if (null !== ($value = $package->getDistSha1Checksum())) { + $data['dist']['shasum'] = $value; + } if ($mirrors = $package->getDistMirrors()) { $data['dist']['mirrors'] = $mirrors; } diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 303cc3c13..c269afa22 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -85,7 +85,7 @@ class ArrayLoader implements LoaderInterface } $package->setSourceType($config['source']['type']); $package->setSourceUrl($config['source']['url']); - $package->setSourceReference($config['source']['reference']); + $package->setSourceReference(isset($config['source']['reference']) ? $config['source']['reference'] : null); if (isset($config['source']['mirrors'])) { $package->setSourceMirrors($config['source']['mirrors']); }