Steps to reproduce
Create small project like this
composer.json
{
"require": {
"psr/log": "^3.0"
}
}
index.php
<?php
require __DIR__ . '/vendor/autoload.php';
print_r(Composer\InstalledVersions::getInstalledPackagesByType('library'));
Run the script
Output
Array
(
[0] => __root__
[1] => psr/log
[2] => __root__
[3] => psr/log
)
Note that entries are duplicated.