Unexpected array wrapping behavior
Array wrapping behavior is a bit counter-intuitive here. With a relatively short array literal, the formatting is kept as-is:
class TestMain {
static function main() {
UTest.run([
new ArrayHelperTest(),
new IdentifierHelperTest(),
new ImportHelperTest(),
new PathHelperTest(),
new PositionHelperTest(),
]);
}
}
However, with a few more:
class TestMain {
static function main() {
UTest.run([
new ArrayHelperTest(),
new IdentifierHelperTest(),
new ImportHelperTest(),
new PathHelperTest(),
new PositionHelperTest(),
new RangeHelperTest(),
new TypeHelperTest(),
new RenameResolverTest(),
new HelperTest(),
new TokenTreeTest()
]);
}
}
The code turns into this - I guess it switches to a different array wrapping mode:
class TestMain {
static function main() {
UTest.run([
new ArrayHelperTest(), new IdentifierHelperTest(), new ImportHelperTest(), new PathHelperTest(), new PositionHelperTest(), new RangeHelperTest(),
new TypeHelperTest(), new RenameResolverTest(), new HelperTest(), new TokenTreeTest()
]);
}
}
yep, when there is 10 or more items it will switch to fillLine instead of onePerLine....
At some point fillLine has to happen, because if you have dozens of items, then one per line would make for a very long file.
I'm open for discussion if it should start at 10, we might even include additional conditions like item or line length.
At some point
fillLinehas to happen, because if you have dozens of items, then one per line would make for a very long file.
Does it? Not sure I'd ever want it to happen in this case. Checking for item length might make the most sense, since the other wrapping mode is mostly good for int / float arrays, where the items are very short.
My 2 cents: I agree with @Gama11, I don't think I ever wanted it to become fillLine. I prefer slightly longer files that are easier to visually parse and are easier to edit.