The "package" key in a package repository may be set to an array to define multiple versions of a package: https://getcomposer.org/doc/05-repositories.md#package-2
Here is a payload for the test:
"repositories": [
{
"type": "package",
"package": [
{
"name": "smarty/smarty",
"version": "2.0.0",
"dist": {
"url": "https://www.smarty.net/files/Smarty-2.0.0.zip",
"type": "zip"
},
"source": {
"url": "http://smarty-php.googlecode.com/svn/",
"type": "svn",
"reference": "tags/Smarty_2_0_0/distribution/"
},
"autoload": {
"classmap": ["libs/"]
}
},
{
"name": "smarty/smarty",
"version": "3.0.0",
"dist": {
"url": "https://www.smarty.net/files/Smarty-3.0.0.zip",
"type": "zip"
},
"source": {
"url": "http://smarty-php.googlecode.com/svn/",
"type": "svn",
"reference": "tags/Smarty_3_0_0/distribution/"
},
"autoload": {
"classmap": ["libs/"]
}
}
]
}
],
As output I assumed to see repository with array of packages.
Personally I have never seen any project which defines repository packages in this way. Just keep in mind that these changes are breaking because getPackage returns ?ComposerJson right now, but may start to return an array of ComposerJson instances too. I don't really like it because return type becomes mixed ComposerJson|ComposerJson[]|null and will require additional checks in user application to determine what we have inside: is it array or one instance only.
As possible solutions to prevent mixed return type I think it could return array even when there is only one package instance defined. To prevent introduction of breaking changes in v1 this feature could be delayed for the v2 version.
The
"package"key in apackagerepository may be set to an array to define multiple versions of a package: https://getcomposer.org/doc/05-repositories.md#package-2Here is a payload for the test:
As output I assumed to see repository with array of packages.
Personally I have never seen any project which defines repository packages in this way. Just keep in mind that these changes are breaking because
getPackagereturns?ComposerJsonright now, but may start to return an array of ComposerJson instances too. I don't really like it because return type becomes mixedComposerJson|ComposerJson[]|nulland will require additional checks in user application to determine what we have inside: is it array or one instance only.As possible solutions to prevent mixed return type I think it could return array even when there is only one package instance defined. To prevent introduction of breaking changes in v1 this feature could be delayed for the v2 version.