mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Align order of constructor arguments of Index and UniqueConstraint
#6820
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ThomasLandauer on GitHub (Sep 2, 2021).
Feature Request
Summary
Signature of
Index::__construct():Signature of
UniqueConstraint::__construct()I'm suggesting to make the order consistent.
@derrabus commented on GitHub (Sep 5, 2021):
Can you elaborate what problem this change would solve?
@ThomasLandauer commented on GitHub (Sep 6, 2021):
When looking at the attributes, the switched order is inconsistent and therefore confusing:
Especially since a
UniqueConstraintis in fact just a special case of anIndex.I know that you can change the order in the declaration, but then the IDE keeps complaining that they don't match the parameter order ;-)
Would it be a big change to switch them?
@derrabus commented on GitHub (Sep 6, 2021):
Exactly. The point of named arguments is that the order does not matter anymore.
Well, that's a PhpStorm issue. You don't have to adhere to that inspection and you can disable it. There's nothing wrong with using a different order here, so PhpStorm must not raise a flag here imho.
See also https://youtrack.jetbrains.com/issue/WI-62252
Well, now that we've shipped a stable version already, changing the order of the constructor arguments would mean a breaking change for constructor calls with ordered arguments. To my knowledge, the order of arguments was never documented, so the impact is probably low. But still, people might have relied on it.
And that is basically why I asked for the problem that should be solved here. If we consider a BC break, we should be aware of why we're doing this.
@ThomasLandauer commented on GitHub (Sep 6, 2021):
Well, since named arguments are new (PHP 8), there are no established best practices yet. Deviating from the original order might be a no-go in 5 years - or common sense ;-)
If you change it now, it is some work; if you change it in 5 years, it is much work. If you keep it forever, it is zero work ;-)
I have too little insight, just decide either way, and feel free to close this issue...
@derrabus commented on GitHub (Sep 7, 2021):
I think I'd like to hear @beberlei's point of view here.
@ThomasLandauer commented on GitHub (Feb 12, 2024):
Implemented in https://github.com/doctrine/orm/pull/10964 :-)