Legoktm wrote:
There's no need to do it manually. Just tell people to run the phpcs autofixer before they rebase, and the result should be identical to what's already there. And we can have PHPCS run in the other direction for backports ([] -> array()).
Unfortunately, it's not that simple. If you run phpcbf before you rebase, you end up with a commit which changes every instance of array() to [], even in lines the developer didn't touch. Then if any of those phpcbf changes appear close to a recent real change in master, the context won't match and you'll get a conflict.
A simple one-line change in a file with many array literals and many intervening changes in master tends to end up with many conflicts on rebase.
So I wrote a script to do it in a different way:
https://phabricator.wikimedia.org/diffusion/MCUT/browse/master/rebase-long-array
This script runs phpcbf on the base, and separately on the head of the work branch, and then creates a patch based on the difference between the two. So the patch contains short arrays on both sides. Then the patch is applied to master to generate the new commit. I tried this on https://gerrit.wikimedia.org/r/#/c/236508/ and it seemed to work.
-- Tim Starling
wikitech-l@lists.wikimedia.org