Arcade Physics collision objects swapped

In Phaser version 3.19.0 and version 3.17.0 (the only 2 versions I’ve checked) some collision objects get returned in reverse of what’s expected. So when changing from a single sprite to a group, it causes issues.

Version 3.19.0 Line 95870 - the function “collideHandler” contains the return functions:
// A Body
return this.collideSpriteVsSprite(object1, object2, … )
return this.collideSpriteVsGroup(object1, object2, … )
return this.collideSpriteVsTilemapLayer(object1, object2, … )
// GROUPS
return this.collideSpriteVsGroup(object2, object1, … ) <<— the offending line
return this.collideGroupVsGroup(object1, object2, … )
return this.collideGroupVsTilemapLayer(object1, object2, … )
// TILEMAP LAYERS
return this.collideSpriteVsTilemapLayer(object2, object1, … ) <<— probable issues here too
return this.collideGroupVsTilemapLayer(object2, object1, … ) <<— probable issues here too

I was originally testing a sprite (object1) against a sprite (object2) which invoked “collideSpriteVsSprite” which returns (object1, object2). I changed the first sprite to a group which invokes “collideSpriteVsGroup”, which then swaps the output to (object2, object1).

Yes, I understand that I can easily swap my sprite and group, and similarly when I’m testing a sprite against sprite, reverse the order to match when I’m testing against a group.

I would suggest as an addition or alternate in the GROUPS category, a method of “collideGroupVsSprite” so the output remains in the order of (object1, object2).

I think this used to be in the docs. Re. collideCallback and processCallback:

The two objects will be passed to this function in the same order in which you specified them, unless you are colliding Group vs. Sprite, in which case Sprite will always be the first parameter.